0
Answer

how to connectin to MS Access

Jia En

Jia En

18y
1.8k
1
Hello.. How do I connect to MS Access? And I put the mdb in debug folder... I try this: try { string connString = @"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=H:\MP\Jia En\TCP\client_Timer\bin\Debug\cgaa.mdb"; OleDbConnection conn = new OleDbConnection(connString); conn.Open(); string query = "INSERT INTO tblLogin (userName, machName, loginDT) VALUES('"+fm.userName+"','"+ fm.machName+ "', '" +fm.startTime+"')"; OleDbCommand cmd = new OleDbCommand(query, conn); cmd.ExecuteNonQuery(); MessageBox.Show("Successfully Inserted","Info",MessageBoxButtons.OK,MessageBoxIcon.Information); conn.Close(); } catch(System.Data.OleDb.OleDbException ex) { MessageBox.Show("Insertion Error, Try Again","Info",MessageBoxButtons.OK,MessageBoxIcon.Error); }