VB.NET做基于WEB的管理系统DATAGRID中数据
修改的问题 我用VB.NET和
sql SERVER2000做的这个管理系统,直接把
sqlDataAdapter控件拖到一个
页面,然后设置了数据源.以下是部分
代码,也是这里出现问题的,请高人指点,万分感谢! Private Sub DataGrid1_UpdateCommand(ByVal source As Object,ByVal e As DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand Dim inRoeIndex As Integer Dim strBuildingName,strBuildingLocate,strSquareArea,strHouseNumber,strConstArea,strContainArea,strGreenArea,strDevelopDate,strRemark As String inRoeIndex = e.Item.ItemIndex() strBuildingName = DirectCast(DataGrid1.Items(inRoeIndex).Cells(0).Controls(0),Text
Box).Text strBuildingLocate = DirectCast(DataGrid1.Items(inRoeIndex).Cells(1).Controls(0),Text
Box).Text strSquareArea = DirectCast(DataGrid1.Items(inRoeIndex).Cells(2).Controls(0),Text
Box).Text strHouseNumber = DirectCast(DataGrid1.Items(inRoeIndex).Cells(3).Controls(0),Text
Box).Text strConstArea = DirectCast(DataGrid1.Items(inRoeIndex).Cells(4).Controls(0),Text
Box).Text strContainArea = DirectCast(DataGrid1.Items(inRoeIndex).Cells(5).Controls(0),Text
Box).Text strGreenArea = DirectCast(DataGrid1.Items(inRoeIndex).Cells(6).Controls(0),Text
Box).Text strDevelopDate = DirectCast(DataGrid1.Items(inRoeIndex).Cells(7).Controls(0),Text
Box).Text strRemark = DirectCast(DataGrid1.Items(inRoeIndex).Cells(8).Controls(0),Text
Box).Text Dim objConnection As
sqlConnection Dim myCommand As
sqlCommand Dim myDataAdapter As
sqlDataAdapter Dim myDataset As New DataSet Dim strConnection As String strConnection = workstation id=DUKE;packet size=4096;user id=sa;initial catalog=house;persist security info=False objConnection = New
sqlConnection(strConnection) myCommand = New
sqlCommand( update buildinginfo set buildinglocate= + strBuildingLocate + where buildingname= + strBuildingName + ) Try objConnection.Open() myCommand.ExecuteNonQuery() Catch ex As Exception Response.Write(ex.Message) End Try objConnection.Close() myCommand = Nothing End Sub 我把编辑,
删除的按钮也
添加到了DATAGRID中,不过在点更新以后,只有buildinglocate能够更新到
数据库中,UPDATE的
sql语句我不会写,所以这里
sql语句提供的
代码不完整,请问怎么能够实现对一条记录的每个字段都更新?UPDATE语句该怎么写? __________________________________________________________________________ 写
sql语句不就都更新了吗 myCommand=New
sqlCommand( update buildinginfo set buildinglocate= & strBuildingLocate &,buildingname= & strBuildingName & .... where ...... ) 不知我理解的对不对 __________________________________________________________________________ 用update语句 __________________________________________________________________________ 看了很多,都晕了,学习中。 __________________________________________________________________________
原文链接:https://www.f2er.com/vb/263713.html