Hi All,
Im trying to Insert a new row into a database and refresh the dataset.
This is what I have so far:
void ButtonInsert(object s, EventArgs e)
{
string connectionString = null;
OleDbConnection connection;
OleDbCommand cmd = new OleDbCommand();
string sql = null;
connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;data source=Book.mdb";
connection = new OleDbConnection(connectionString);
sql = "INSERT INTO Books (BookKey, Title, Pages, AuthorKey, PublisherID) Values ('12','A1BC','999','12','14')";
connection.Open();
cmd.CommandText = sql;
cmd.Connection = connection;
cmd.Parameters.Add("@Title", OleDbType.VarChar, 50, "Title");
cmd.Parameters.Add("@BookKey", OleDbType.VarChar, 50, "BookKey");
cmd.ExecuteNonQuery();
connection.Close();
refreshlist(); // restarts the form
}
When i click the Insert Button it inputs the data into the database but its doesnt seem to appear on the dataset/datatable.
I had an exceptChanges to the dataset but that didnt seem to do much good. just wondering what i am missing.
Eventually I want it so that it inserts from inputed data
Thank you in Advance
Regards