Please try below code to write in MS ACCESS databse using C# Window Application:
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\amar\Documents\Database1.accdb"); conn.Open(); using (System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand()) { cmd.Connection = conn; cmd.CommandText = "Insert Into Employee (UserName, fname, sname, email) values ('amar','Amar Prakash','Jaiswal','[email protected]')"; cmd.ExecuteNonQuery(); } conn.Close();
how to insert values using text box???
For string type
‘” + txtName.Text + “‘
and for int type/float type/decimal type
” + txtAge.Text + ”
so in values section of insert command replace hard-coded value as below
values (‘” + txtFName.Text + “‘ ,'” + txtFullName.Text + “‘ ,'” + txtLName.Text + “‘ ,'” + txtEmail.Text + “‘ )
Have a look at here
Using Access Database with c# — geeksprogrammings.blogspot.com
http://geeksprogrammings.blogspot.com/2013/10/connect-access-database-with-c.html
For Deletion Record
http://geeksprogrammings.blogspot.com/2013/09/delete-record-from-access-database.html