User1253203540 posted
hello, i have a problem when i try ot delete a row in a gridview, everythiing is display ok except when the delete function is run. There are three columns in my Access, ID = Auto First & Last Name = Text
the error says data type mismatch in criteria expression -> cmd.ExceuteNonQuery();
This is the code for delete:
protected
void
ResultGridView_RowDeleting(object
sender, GridViewDeleteEventArgs
e)
{
string
Connection = "Provider=Microsoft.Jet.OLEDB.4.0;
" +
"Data
Source=D:/Customers.mdb";
OleDbConnection
con = new
OleDbConnection(Connection);
OleDbCommand
cmd = new
OleDbCommand();
cmd.Connection = con;
cmd.CommandText ="delete
from tblCustomers where ID='" + ResultGridView.DataKeys[e.RowIndex].Values[0].ToString()
+ "'";
con.Open();
cmd.ExecuteNonQuery();
con.Close();
FillVendorGrid();
}