vb.net中的数据列表更新编码 [英] datalist updae coding in vb.net
本文介绍了vb.net中的数据列表更新编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
受保护的 子 DataList1_UpdateCommand( As ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)>句柄 DataList1.UpdateCommand
Dim AgentId As 字符串 = DataList1.DataKeys (e.Item.ItemIndex).ToString()
DataList1.DataKeys(e.Item.ItemIndex).ToString()
Dim 名称 As TextBox = CType (e .Item.FindControl(" ),文本框)
str = "
尝试
openConnection(con)
str = " &名称,文字和文字" & AgentId& "
cmd = 新建 OleDbCommand(str,con)
cmd.ExecuteNonQuery()
LoadData()
DataList1.EditItemIndex = -1
捕获,例如 As 异常
警报(MessageType.Fail)
最后
con.Close()
结束 尝试
结束 子
在上述程序中,当程序控制传递给openConnection(con)时,它进入异常块.我该怎么办?尚未建立.检查您的连接字符串,并确保您的SQL Server可用.
干杯
Protected Sub DataList1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.UpdateCommand
Dim AgentId As String = DataList1.DataKeys(e.Item.ItemIndex).ToString()
DataList1.DataKeys(e.Item.ItemIndex).ToString()
Dim Name As TextBox = CType(e.Item.FindControl("txtName"), TextBox)
str = ""
Try
openConnection(con)
str = "UPDATE Agent_Master SET A_Name='" & Name.Text & "'WHERE AgentId ='" & AgentId & "'"
cmd = New OleDbCommand(str, con)
cmd.ExecuteNonQuery()
LoadData()
DataList1.EditItemIndex = -1
Catch ex As Exception
alert(MessageType.Fail)
Finally
con.Close()
End Try
End Sub
in he above program control goes to exception block when it passes the openConnection(con).what will i do ?
解决方案
Probably your connection string is invalid or a connection can''t be established. Check your connection string and make sure that you sql server is available.
Cheers
这篇关于vb.net中的数据列表更新编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文