Hi Guys need a bit of help. I right a c# program that connects to a database and do various things. One of them is to delete a record. currently I can delete a record that i specify but i want it to delete a selected row in the dataset.
string connectionString = null;
OleDbConnection connection;
OleDbDataAdapter oledbAdapter = new OleDbDataAdapter();
string sql = null;
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=Book.mdb";
connection = new OleDbConnection(connectionString);
sql = "delete from Books where BookKey = ?";
try
{
connection.Open();
oledbAdapter.DeleteCommand = connection.CreateCommand();
oledbAdapter.DeleteCommand.CommandText = sql;
oledbAdapter.DeleteCommand.Parameters.Add("BookKey", OleDbType.Char, 0, "BookKey");
MessageBox.Show("row deleted");
}
catch (Exception ex)
{
MessageBox.Show (ex.ToString());
}
finally
{
connection.Close();
This is the code. right now it will only delete whatever number i put in the sql command it doesnt like the question mark.
any suggestions would be great
Thank You