Monika Galińska February 2016
Error in delete query using asp.net
i trying delete some rows using GridViews.
protected void Button1_Click(object sender, EventArgs e)
Session["ID_Oosby"] = GridView1.SelectedRow.Cells.Text;
SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["RentCarConnectionString"].ConnectionString);
string deleteQuery = "Delete From from Klienci Where IDOsoby = @idosoby ";
SqlCommand com2 = new SqlCommand(deleteQuery, conn1);
catch (Exception ex)
Response.Write("Nie udąło sie usunac uzytkownika" + ex.ToString());
But when i execute it I receive error message
System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'from'. w System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
Any idea what is wrong?
Harsh February 2016
Change sql query to:
string deleteQuery = "Delete From Klienci Where IDOsoby = @idosoby ";
You have two FROM clauses causing the exception.
Asked in February 2016
Viewed 3,972 times
Answered 1 times
Leave an answer
Quote of the day: live life