coulmn count is autonumber I want to Delete a row Where "Where(Table1.count)='" + count1 + "'"; but I dont know what should be the type of count1 !!! When I use "Where(Table1.count)=9"; I dont have any problem & the row with id numbr 9 will be deleted But my id number is changeable!!! the full code is

int count1 = Convert.ToInt32(textBox2.Text);
        OleDbCommand MyOleDbComm2 = new OleDbCommand();
        ObjConn2.Open();
        MyOleDbComm2.CommandText =
            MyOleDbComm2.CommandText =
            "DELETE FROM Table1 " +
            "Where(Table1.count)='" + count1 + "'";
        MyOleDbComm2.Connection = ObjConn2;
        MyOleDbComm2.ExecuteNonQuery();
        ObjConn2.Close();
有帮助吗?

解决方案

you should keep its type to whatever is the type of id column in database.

Though in your case here if you want to use count1 only in this query you can keep it string/int. I also see a problem in your query. it should be

"DELETE FROM Table1 Where(Table1.count)=" + count1; //note i have removed single quotes

unless your id column is string in database.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top