2011-02-16 31 views
0

此UPDATE查询不会更新任何值,也不会产生任何错误......该查询中的问题是什么?此更新查询中的问题是什么?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 
    Try 
     Using conn = New SqlConnection(constr) 
     Using cmd = conn.CreateCommand() 
     conn.Open() 
     Dim sql As String = "UPDATE hotels SET city [email protected], hotel [email protected], location [email protected], price [email protected], category [email protected], short [email protected], details [email protected] WHERE hotelid [email protected]" 
     cmd.CommandText = sql 
     cmd.Parameters.AddWithValue("@city", TextBox1.Text) 
     cmd.Parameters.AddWithValue("@hotel", TextBox2.Text) 
     cmd.Parameters.AddWithValue("@location", TextBox3.Text) 
     cmd.Parameters.AddWithValue("@price", TextBox4.Text) 
     cmd.Parameters.AddWithValue("@category", Rating1.CurrentRating) 
     cmd.Parameters.AddWithValue("@short", TextBox6.Text) 
     cmd.Parameters.AddWithValue("@details", Editor1.Content) 
     cmd.Parameters.AddWithValue("@hotelid", Request.QueryString("hotelid")) 
     cmd.ExecuteNonQuery() 
     End Using 
     End Using 
    Catch ex As Exception 
     Response.Write(ex.Message) 
    End Try 

提取的查询:

UPDATE hotels 
SET city = @city, hotel = @hotel, 
    location = @location, price = @price, 
    category = @category, short = @short, details = @details 
WHERE hotelid = @hotelid 
+2

'hotelid'设置为什么? – 2011-02-16 10:23:26

回答

1

没有什么明显的错误与SQL的,你说你没有得到任何错误,所以我猜你的Request.QueryString(“hotelid” )实际上并没有返回除null之外的任何东西(这意味着你的UPDATe不会更新任何东西)。 Request.QueryString(“hotelid”)的值是多少?Count?