此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 =@city, hotel =@hotel, location =@location, price =@price, category =@category, short =@short, details =@details WHERE hotelid =@hotelid"
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
答案 0 :(得分:1)
SQL没有明显的错误,你说你没有收到任何错误,所以我猜你的Request.QueryString(“hotelid”)实际上并没有返回null(这意味着你的UPDATe不会更新任何内容)。 Request.QueryString(“hotelid”)的值是多少。计数?