What was the problem in this update query?
This UPDATE query doesn't update any value nor producing any error ... what was the problem in that query ?
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 =@hote开发者_C百科lid"
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
Extracted query:
UPDATE hotels
SET city = @city, hotel = @hotel,
location = @location, price = @price,
category = @category, short = @short, details = @details
WHERE hotelid = @hotelid
There's nothing obviously wrong with the SQL, and you say you're not getting any errors, so I'd guess that your Request.QueryString("hotelid") isn't actually returning anything apart from null (which means your UPDATe won't update anything). What is the value of Request.QueryString("hotelid").Count?
精彩评论