K
Keith Smith
I use this method to read from my Access database...
DataSet ReadDatabase(string strSQL)
{
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\database.MDB";
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter( strSQL, myConn );
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet);
return dtSet;
myConn.Dispose();
}
So then, for example, if I want to call the above method I do it this way...
DataSet x;
x = ReadDatabase("SELECT * FROM users WHERE (username='tom' AND
password='password');");
My way of doing this seems very logical to me...but I am still learning. Is
there anything wrong (or inefficient) with me doing this? The above code
seems to work fine.
DataSet ReadDatabase(string strSQL)
{
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\database.MDB";
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter( strSQL, myConn );
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet);
return dtSet;
myConn.Dispose();
}
So then, for example, if I want to call the above method I do it this way...
DataSet x;
x = ReadDatabase("SELECT * FROM users WHERE (username='tom' AND
password='password');");
My way of doing this seems very logical to me...but I am still learning. Is
there anything wrong (or inefficient) with me doing this? The above code
seems to work fine.