SqlConnection con = new SqlConnection("Data Source=APPLE;Initial Catalog=sam;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
string str1 = "DELETE * FROM AU_Delete";
cmd.CommandText = str1;
cmd.ExecuteNonQuery();
con.Close();
This is my coding for delete button it's showing error : Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '*'.
what is the problem in my coding?
Santhosh Kumar JayaramanPosted Aug 21, 2012, 5:38 AM
You can write query as
delete table AU_Delete
or
delete from table au_Delete.
you have to use * only in select queries.
try this
Hemant KumarPosted Aug 21, 2012, 5:17 AM
you can't write '*' for the delete Statements
string Query="delete from AU_DELETE";
Naresh AvariPosted Aug 21, 2012, 4:46 AM
Remove '*' from your SQL Query and use
string str1 = "DELETE FROM AU_Delete";
You don't need to specify '*' for DELETE statement.