【发布时间】:2014-10-18 13:37:54
【问题描述】:
我有一个数据网格视图,它由我的 microsoft mysql 数据库上的一个表填充我的问题是我需要选择一行,然后它的值出现在我已经解决的文本框中。但是现在,如果要发生任何更改,我想创建一个更新函数来使用所做的更改更新记录。我已经尝试过,但直到现在都失败了。
Public Sub AddMember(FirstName As String, Surname As String, Admin As Integer)
Try
Dim strInsert As String = _
"UPDATE test Firstname='this should be the value entered in the text box' " & _
"WHERE Firstname = 'this should equal to the value selected from the datagrid view'"
MsgBox(strInsert)
SQLCon.Open()
SQLCmd = New SqlCommand(strInsert, SQLCon)
SQLCmd.ExecuteNonQuery()
SQLCon.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
【问题讨论】:
-
uuum,您在该查询中缺少 WHERE 子句。 SQL 如何知道您要更新的特定结果?
-
对不起,我再次编辑了代码
标签: mysql sql-server vb.net visual-studio-2010