B
Brian
Was browsing around online for code to connect to a database usign ADO
and C#... and i found this very simple but useful reference
(http://www.c-sharpcorner.com/database/db_list.asp)
However, implementing this into my own project does seem to work.
I'm getting an error: 'System.Data.OleDb.OleDbCommand' does not
contain a definition for 'Fill'
Why would this be?
PS - code below for reference.
private void Form1_Load(object sender, System.EventArgs e)
{
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=photoDB.MDB";
string strSQL = "SELECT * FROM photos" ;
// create Objects of ADOConnection and ADOCommand
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbCommand myCmd = new OleDbCommand( strSQL, myConn );
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "photos" );
DataTable dTable = dtSet.Tables[0];
foreach( DataRow dtRow in dTable.Rows )
{
listBox1.Items.Add( dtRow["Name"].ToString());
listBox1.Items.Add( dtRow["Address"].ToString());
}
and C#... and i found this very simple but useful reference
(http://www.c-sharpcorner.com/database/db_list.asp)
However, implementing this into my own project does seem to work.
I'm getting an error: 'System.Data.OleDb.OleDbCommand' does not
contain a definition for 'Fill'
Why would this be?
PS - code below for reference.
private void Form1_Load(object sender, System.EventArgs e)
{
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=photoDB.MDB";
string strSQL = "SELECT * FROM photos" ;
// create Objects of ADOConnection and ADOCommand
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbCommand myCmd = new OleDbCommand( strSQL, myConn );
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "photos" );
DataTable dTable = dtSet.Tables[0];
foreach( DataRow dtRow in dTable.Rows )
{
listBox1.Items.Add( dtRow["Name"].ToString());
listBox1.Items.Add( dtRow["Address"].ToString());
}