[VB.NET]VB.NET做基于WEB的管理系统DATAGRID中数据修改的问题

前端之家收集整理的这篇文章主要介绍了[VB.NET]VB.NET做基于WEB的管理系统DATAGRID中数据修改的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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),TextBox).Text strBuildingLocate = DirectCast(DataGrid1.Items(inRoeIndex).Cells(1).Controls(0),TextBox).Text strSquareArea = DirectCast(DataGrid1.Items(inRoeIndex).Cells(2).Controls(0),TextBox).Text strHouseNumber = DirectCast(DataGrid1.Items(inRoeIndex).Cells(3).Controls(0),TextBox).Text strConstArea = DirectCast(DataGrid1.Items(inRoeIndex).Cells(4).Controls(0),TextBox).Text strContainArea = DirectCast(DataGrid1.Items(inRoeIndex).Cells(5).Controls(0),TextBox).Text strGreenArea = DirectCast(DataGrid1.Items(inRoeIndex).Cells(6).Controls(0),TextBox).Text strDevelopDate = DirectCast(DataGrid1.Items(inRoeIndex).Cells(7).Controls(0),TextBox).Text strRemark = DirectCast(DataGrid1.Items(inRoeIndex).Cells(8).Controls(0),TextBox).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

猜你在找的VB相关文章