Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

insert data to access database c#

string constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|your_DataBase_Name.accdb;";
                   OleDbConnection Con = new OleDbConnection(constr);
                   Con.Open();
                   OleDbCommand com = new OleDbCommand();
                   com.Connection = Con;
                   com = new OleDbCommand("your insert command here", Con);
                   int Num=com.ExecuteNonQuery();
                   if (Num != 0)
                   {
                       MessageBox.Show("Record Successfully Added....", "Add Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                       this.Close();
                   }
                   else
                   {
                       MessageBox.Show("Record is not Added....", "Add Record Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   }
Source by www.codeproject.com #
 
PREVIOUS NEXT
Tagged: #insert #data #access #database
ADD COMMENT
Topic
Name
4+4 =