B
Brian
Funny you mention that because that's why i didn't include more
information.. for some reason, i couldn't compile this try.. catch
block.
Can anyone give me the correct structure if i am missing something?
Does it have to be in a Main() method or anything? Haven't really used
try.. catch blocks much before.
try
{
// load categories
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=photoDB.MDB";
string strSQL = "SELECT * FROM categories" ;
// create Objects of ADOConnection and ADOCommand
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter( strSQL, myConn );
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "categories" );
DataTable dTable = dtSet.Tables[0];
foreach( DataRow dtRow in dTable.Rows )
{
cboCategory.Items.Add( dtRow["category"].ToString());
}
myConn.Close();
}
catch(Exception e)
{
MessageBox.Show("" + e.Message);
}
information.. for some reason, i couldn't compile this try.. catch
block.
Can anyone give me the correct structure if i am missing something?
Does it have to be in a Main() method or anything? Haven't really used
try.. catch blocks much before.
try
{
// load categories
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=photoDB.MDB";
string strSQL = "SELECT * FROM categories" ;
// create Objects of ADOConnection and ADOCommand
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter( strSQL, myConn );
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "categories" );
DataTable dTable = dtSet.Tables[0];
foreach( DataRow dtRow in dTable.Rows )
{
cboCategory.Items.Add( dtRow["category"].ToString());
}
myConn.Close();
}
catch(Exception e)
{
MessageBox.Show("" + e.Message);
}