编辑记录不会在asp.net中产生任何结果
我有以下代码来填充我的数据集(ASP.Net)。
Dim conStr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbTest.mdf;Integrated Security=True;User Instance=True"
Dim sqlQry As String = "SELECT * FROM tblTest"
Dim dAdt As New SqlDataAdapter(sqlQry, conStr)
Dim dSet As New DataSet()
dAdt.Fill(dSet, "tblTest")
然后我使用以下命令来编辑我的记录
Dim dRow As DataRow
dRow = dSet.Tables("tblTest").Rows(1)
dRow.BeginEdit()
dRow.Item("Name") = txtName.Text
dRow.EndEdit()
dSet.Tables("tblTest").AcceptChanges()
,它不会生成任何错误,但也不会编辑记录。当我尝试使用删除命令删除记录时,也会发生同样的情况。请指教。 谢谢
I have following code to fill my dataset (ASP.Net).
Dim conStr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbTest.mdf;Integrated Security=True;User Instance=True"
Dim sqlQry As String = "SELECT * FROM tblTest"
Dim dAdt As New SqlDataAdapter(sqlQry, conStr)
Dim dSet As New DataSet()
dAdt.Fill(dSet, "tblTest")
Then I am using following to edit my record
Dim dRow As DataRow
dRow = dSet.Tables("tblTest").Rows(1)
dRow.BeginEdit()
dRow.Item("Name") = txtName.Text
dRow.EndEdit()
dSet.Tables("tblTest").AcceptChanges()
it does not generate any error but does not edit the record too. Same is happening when I try to delete record using delete command. Please advise.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你需要在 AcceptChanges 之前调用“update”。
像这样的东西:
I think you need to call "update" before AcceptChanges.
Something like:
尝试添加 BeginEdit() 和 AcceptChanges() 方法,如下所示:
Try adding the BeginEdit() and AcceptChanges() methods, like this: