Ctwizzy
February 11th, 2005, 08:54 AM
I have followed the solution my Microsoft and other sites none work.
here is my code
private void tbPunch_Click(object sender, System.EventArgs e)
{
String conString = " ";
try
{
//contructor accepts the database path
conString=@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Documents and Settings\Me\My Documents\Visual Studio Projects\DB\testDB.mdb";
DataSet oDS = new DataSet();
con = new OleDbConnection(conString);
con.Open(); ***** this is where the error is
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
myDataAdapter = new OleDbDataAdapter("Select * From clockTable", con);
OleDbCommandBuilder myCmdBuilder = new OleDbCommandBuilder(myDataAdapter);
myDataAdapter.Fill(myDtPunch);
this.ShowCurrentRecord();
}
catch (Exception ex)
{
MessageBox.Show("conString = " + conString + " Error in connection : "+ex.Message);
}
finally
{
// dispose of open objects
if (con != null)
con.Close();
} //finally
}
private void ShowCurrentRecord()
{
if (myDtPunch.Rows.Count==0)
{
test1.Text = "No Entries";
test2.Text = "No Entries";
return;
}
test1.Text = myDtPunch.Rows[rowPosition]["IDnum"].ToString();
test2.Text = myDtPunch.Rows[rowPosition]["position"].ToString();
}
Anyone know how to fix this, its put a huge halt in me continuing,
thanks
here is my code
private void tbPunch_Click(object sender, System.EventArgs e)
{
String conString = " ";
try
{
//contructor accepts the database path
conString=@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Documents and Settings\Me\My Documents\Visual Studio Projects\DB\testDB.mdb";
DataSet oDS = new DataSet();
con = new OleDbConnection(conString);
con.Open(); ***** this is where the error is
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
myDataAdapter = new OleDbDataAdapter("Select * From clockTable", con);
OleDbCommandBuilder myCmdBuilder = new OleDbCommandBuilder(myDataAdapter);
myDataAdapter.Fill(myDtPunch);
this.ShowCurrentRecord();
}
catch (Exception ex)
{
MessageBox.Show("conString = " + conString + " Error in connection : "+ex.Message);
}
finally
{
// dispose of open objects
if (con != null)
con.Close();
} //finally
}
private void ShowCurrentRecord()
{
if (myDtPunch.Rows.Count==0)
{
test1.Text = "No Entries";
test2.Text = "No Entries";
return;
}
test1.Text = myDtPunch.Rows[rowPosition]["IDnum"].ToString();
test2.Text = myDtPunch.Rows[rowPosition]["position"].ToString();
}
Anyone know how to fix this, its put a huge halt in me continuing,
thanks