View Single Post
  #1 (permalink)  
Old February 22nd, 2006, 04:05 PM
thas123 thas123 is offline
Authorized User
 
Join Date: Jan 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with delete statement

here is the code for del.aspx

<form name="form1" method="post" action="table1.aspx">
        <%
        dim cv as string
    dim str as string
    Dim strConnection As String = "user id=sa;password=;server=.;initial catalog=students"
    Dim cn As SqlConnection = New SqlConnection(strConnection)
     cn.Open()
     str=(Request.QueryString("cv"))
         Dim strSelect As String = "DELETE teachers where TID ='"& str &"' "
     response.write(strSelect)
    ' response.End()
     Dim sqlComm As new SqlCommand(strSelect,cn)
     try
     sqlComm.ExecuteNonQuery()
     catch ex as exception
     response.Write(ex.ToString())
     finally
     cn.close()
     end try
'response.redirect("Teachview.aspx")

        %>
        </form>
my sql statement passing value is correct,

DELETE teachers where TID ='1' System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ' '. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ASP.del_aspx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) in http://localhost/add/del.aspx:line 32


Line 32 is the sqlcomm.executenonquery() method.its in this statement error is there.i duno wats wrong.if anybody knows pls tel me.

Reply With Quote