在vb.net中,,,
我用下列代码来更新DataGridView上数值,,,,,,,,更新之后,,,,我想把更新的数据保存到数据库中去........
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim sSelectCmd As String
Dim sMemberID As String, sFrom As String
Dim sParentID As Integer
Dim sobject As String, sTableAlias As String
Dim Fdt As DataSet = New DataSet sMemberID = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value.ToString
sFrom = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(1).Value.ToString
sParentID = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(2).Value.ToString sobject = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(3).Value.ToString
sTableAlias = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(4).Value.ToString
Dim adapter As SqlDataAdapter
sSelectCmd = "Update dicFormObjectCond set TableAlias = '" & sTableAlias & "' ,ObjectID ='" & sobject & "' "
sSelectCmd = sSelectCmd & " where MemberID = '" & sMemberID & "' and "
sSelectCmd = sSelectCmd & " FormID = '" & sFrom & "' and ParentID = '" & sParentID & "' " DBopen()
adapter = New SqlDataAdapter ' adapter.SelectCommand = New SqlCommand(sSelectCmd, Conn)
adapter.SelectCommand = New SqlCommand(sSelectCmd, Conn) ' Dim builder As SqlCommandBuilder = New SqlCommandBuilder(adapter)
Dim builder As SqlCommandBuilder
builder = New SqlCommandBuilder(adapter)
adapter.Fill(Fdt)
builder.GetUpdateCommand() ''到这里就读不过了..
adapter.Update(Fdt) End Sub
报错好象为"Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information"
为什么咯 /////////////
我用下列代码来更新DataGridView上数值,,,,,,,,更新之后,,,,我想把更新的数据保存到数据库中去........
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim sSelectCmd As String
Dim sMemberID As String, sFrom As String
Dim sParentID As Integer
Dim sobject As String, sTableAlias As String
Dim Fdt As DataSet = New DataSet sMemberID = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value.ToString
sFrom = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(1).Value.ToString
sParentID = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(2).Value.ToString sobject = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(3).Value.ToString
sTableAlias = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(4).Value.ToString
Dim adapter As SqlDataAdapter
sSelectCmd = "Update dicFormObjectCond set TableAlias = '" & sTableAlias & "' ,ObjectID ='" & sobject & "' "
sSelectCmd = sSelectCmd & " where MemberID = '" & sMemberID & "' and "
sSelectCmd = sSelectCmd & " FormID = '" & sFrom & "' and ParentID = '" & sParentID & "' " DBopen()
adapter = New SqlDataAdapter ' adapter.SelectCommand = New SqlCommand(sSelectCmd, Conn)
adapter.SelectCommand = New SqlCommand(sSelectCmd, Conn) ' Dim builder As SqlCommandBuilder = New SqlCommandBuilder(adapter)
Dim builder As SqlCommandBuilder
builder = New SqlCommandBuilder(adapter)
adapter.Fill(Fdt)
builder.GetUpdateCommand() ''到这里就读不过了..
adapter.Update(Fdt) End Sub
报错好象为"Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information"
为什么咯 /////////////
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货