To insert data to the Microsoft Access database, the code snippet below will do the job.
string fileName = "YourDatabaseFilename";
string password = "TheDatabasePassword";
string tableName = "TableName";
string columnName = "NewColumn";
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + fileName +
".accdb; Jet OLEDB:Database Password =" + password + "; Mode=12";
OleDbConnection con = new OleDbConnection(connectionString);
con.Open();
string query =
"INSERT INTO " + tableName + "(" + columnName +
") VALUES('" + info + "')";
OleDbCommand Command = new OleDbCommand(query, con);
Command.ExecuteNonQuery();
con.Close();
No comments:
Post a Comment