我使用dataset和form上的textbox控件绑定了,我想通过在textbox上修改数据,修改完以后无法将源数据库中的数据修改
类代码的代码如下:
Public Function updatedbfromdataset(ByVal dschanges As DataSet, ByVal strsql As String) As Boolean
Dim conn As New SqlConnection(strconnection)
Try
Dim dtadapter As New SqlDataAdapter(strsql, conn)
Dim custcb As SqlCommandBuilder = New SqlCommandBuilder(dtadapter)
'open the connection
conn.Open()
'save the dataset changes back to the database
dtadapter.Update(dschanges)
'return success
updatedbfromdataset = True
Finally
'close the connection
conn.Close()
End Try
End Function
控件button的代码如下
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
If dsemployees.HasChanges(DataRowState.Modified) Then Exit Sub
Dim changesdataset As DataSet
changesdataset = dsemployees.GetChanges(datarowstate.modified)
Dim strsql As String = "select 姓名,年龄,性别,身份证号,户口所在地,联系电话,申请前职业,名称字号,从业人数,营业面积,产权,资金数额,组成形式,经营范围,经营内容,注册ID,备注 from zhizhaoguanli"
Dim ccommon As New clsCommon
ccommon.updatedbfromdataset(changesdataset, strsql)
End Sub
错误代码如下:
未处理的“System.ArgumentNullException”类型的异常出现在 system.data.dll 中。
其他信息: 值不能为空。
请大侠们帮帮我,看看是哪里出错了,谢谢,本人在线等,,,急急急
[此贴子已经被作者于2005-11-10 1:54:03编辑过]