巫启贤太傻现场版:datagrid更新数据时出现了问题

来源:百度文库 编辑:高校问答 时间:2024/05/06 02:28:29
我在用datagrid更新数据时,运行时没什么错误,但是在textbox中修改数据后,点击更新时数据却没什么变化.不知道怎么回事?这是我再 mfdg_UpdateCommand的代码.麻烦各位高手帮我看看哪里出错了,帮我改改,谢谢!!!!
???? Dim firstname As String
????Dim lastname As String
Dim CurrentTextBox As TextBox
CurrentTextBox = e.Item.Cells(1).Controls(1)
firstname = CurrentTextBox.Text
CurrentTextBox = e.Item.Cells(2).Controls(1)
lastname = CurrentTextBox.Text

If conn.State = ConnectionState.Closed Then
conn.Open()

End If
Dim str As String = "UPDATE mfuser SET firstName = '" & firstname.Replace("''", "''") & "',lastName = '" & lastname.Replace("''", "''") & "' WHERE ID= '" & e.Item.Cells(0).Text & "'"

Dim cmd As New OleDb.OleDbCommand(str, conn)
cmd.Connection = conn
cmd.CommandText = str
cmd.ExecuteNonQuery()
cmd.Connection.Close()
mfdg.EditItemIndex = -1
With Me.mfdg()
.DataSource = dst
.DataBind()

End With

Dim str As String = "UPDATE mfuser SET firstName = '" & firstname.Replace("''", "''") & "',lastName = '" & lastname.Replace("''", "''") & "' WHERE ID= '" & e.Item.Cells(0).Text & "'" <最后这个单引号另一半在哪?我好像没找到.