新手问一个datagrid简单问题>?
修改代码如下:
Sub edits(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
'DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.EditItemIndex = CInt(e.Item.ItemIndex)
bind("2003-8-24")
End Sub
Sub cancels(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
DataGrid1.EditItemIndex = -1
bind("2003-8-24")
End Sub
Sub updates(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
Dim myconnection As OleDbConnection
Dim mycommand As OleDbCommand
Dim textbox1
Dim worder_name As String
STR = "PROVIDER=SQLOLEDB;DATA SOURCE=localhost;UID=pms_db;PWD=zhong7829151;DATABASE=pms_db"
myconnection = New OleDbConnection(STR)
Dim updatecmd As String = "update guapifeng set worder_name=@worder_name where id=432"
mycommand = New OleDbCommand(updatecmd, myconnection)
mycommand.Parameters.Add(New OleDbParameter("@worder_name", OleDbType.VarChar))
TextBox1 = e.Item.Cells(1).Controls(0)
mycommand.Parameters("@worder_name").Value = textbox1.Text
mycommand.Connection.Open()
mycommand.ExecuteNonQuery()
mycommand.Connection.Close()
bind("2003-8-24")
End Sub
异常详细信息: System.Data.OleDb.OleDbException: 必须声明变量 '@worder_name'。
请问是什么问题?