Please see the code below. Your help is very appriciated as this problem is driving me round a bend!
private
void WriteToDatabase(){
OleDbConnection myConn =
null; const string fileName = @"Provider=Microsoft.Jet.OLEDB.4.0;" +@"Data source= C:\C#\Tabels\Tab1.mdb";
try{
myConn =
new OleDbConnection(fileName);}
catch(OleDbException ex){
MessageBox.Show(ex.Message);
}
string insertStatement = "INSERT INTO MKFac(LiveF,UpperM,LowerM,UpperF,LowerF,S600,Output)VALUES(30,30,30,30,30,30,'Hello')";myConn.Open();
MessageBox.Show(myConn.Database);
OleDbCommand insertCommand =
new OleDbCommand(insertStatement,myConn); try{
int count = insertCommand.ExecuteNonQuery();MessageBox.Show ("Wrote : " + count);
insertCommand.Dispose();
}
catch (OleDbException ex){
MessageBox.Show(ex.Message);
}
finally{
if (myConn.State == ConnectionState.Open)myConn.Close();
}
}
P.S. I have checked my Access database tabel and etc.
Many thanks
Behzad.
Replies
Know the answer? Post it — somebody with the same question will find it here.