CIS 407 DeVry iLab 3 of 7 latest
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
18. Create a new class to contain the C# code that will access this dataset. To do so, click Website, Add New Item.<br />
In the Add New Item dialog, select the Class template, and enter clsDataLayer for the name. Make sure the Language<br />
is set to Visual C#. Click “Add”.<br />
Click on image to enlarge.<br />
Add DataLayer Class<br />
19. Click here for text discription <strong>of</strong> this image.<br />
20. If the following message appears, select Yes. You want to make this class available to everything in your solution.<br />
21. Add the following to the top <strong>of</strong> your class, below any other using statements created for you by Visual Studio:<br />
// Add your comments here<br />
using System.Data.OleDb;<br />
using System.Net;<br />
using System.Data;<br />
22. Add the following three functions inside the squiggly braces for the “public class clsDataLayer” class, above the<br />
beginning <strong>of</strong> the “public clsDataLayer()” constructor:<br />
// This function gets the user activity from the tblUserActivity<br />
public static dsUserActivity GetUserActivity(string Database)<br />
{// Add your comments here<br />
dsUserActivity DS;<br />
OleDbConnection sqlConn;<br />
OleDbDataAdapter sqlDA;<br />
// Add your comments here<br />
sqlConn = new OleDbConnection(“PROVIDER=Micros<strong>of</strong>t.Jet.OLEDB.4.0;” +<br />
“Data Source=” + Database);<br />
// Add your comments here<br />
sqlDA = new OleDbDataAdapter(“select * from tblUserActivity”, sqlConn);<br />
// Add your comments here<br />
DS = new dsUserActivity();<br />
// Add your comments here<br />
sqlDA.Fill(DS.tblUserActivity);<br />
// Add your comments here<br />
return DS; }<br />
// This function saves the user activity<br />
public static void SaveUserActivity(string Database, string FormAccessed)<br />
{// Add your comments here<br />
OleDbConnection conn = new OleDbConnection(“PROVIDER=Micros<strong>of</strong>t.Jet.OLEDB.4.0;” +<br />
“Data Source=” + Database);<br />
conn.Open();