更新mysql查询不更新表但只删除指定字段中的数据

时间:2016-03-14 01:45:18

标签: mysql asp.net vb.net odbc

我的更新查询有问题,它没有更新指定的字段,只能删除它们。

这是查询:

Dim myConnection As OdbcConnection
Dim myCommand As OdbcCommand


myConnection = New OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};Database=usermanagement;Server=localhost;UID=root;")
myConnection.Open()

If myConnection.State = 0 Then
    myConnection.Open()
End If


myCommand = New OdbcCommand("update rooms set rmname='" + Request.Form("rmnames") + "',description='" + Request.Form("description") + "', rmprice='" + Request.Form("rmprices") + "' where room_id='" + Request.Form("rooms_id") + "'", myConnection)
myCommand.ExecuteNonQuery()
myConnection.Close()

Response.Redirect("admin.aspx")

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

Dim myConnection As OdbcConnection
Dim myCommand As OdbcCommand


myConnection = New OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};Database=usermanagement;Server=localhost;UID=root;")
myConnection.Open()

If myConnection.State = 0 Then
    myConnection.Open()
End If

myCommand = New OdbcCommand("update rooms set rmname='" + Request.Form("item") + "',description='" + Request.Form("descr") + "', rmprice='" + Request.Form("rate") + "' where room_id=" + Request.Form("room_id"), myConnection)
myCommand.ExecuteNonQuery()
myConnection.Close()

Response.Redirect("admin.aspx")

这是我的答案。