数据集更新 [英] Dataset Update
本文介绍了数据集更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我
我如何更改数据集记录.
我想根据数据集的值在表单加载时更新数据库.
在此先感谢
can anyone tell me
how i can make changes to dataset records.
i would like to update database on form load based on values of dataset.
thanks in advance
推荐答案
看这里:
MSDN:如何通过使用Visual Basic .NET从DataSet对象更新数据库 [ MSDN:如何通过使用Visual C#.NET中的SqlDataAdapter对象更新SQL Server数据库 [
Look here:
MSDN: How to update a database from a DataSet object by using Visual Basic .NET[^]
MSDN: How To Update a SQL Server Database by Using the SqlDataAdapter Object in Visual C# .NET[^]
我已经通过了链接,得到了我需要的代码
i have gone through the link, i got code which i required
''BEGIN EDIT CODE
drCurrent = tblAuthors.Rows.Find("213-46-8915")
drCurrent.BeginEdit()
drCurrent("phone") = "342" & drCurrent("phone").ToString.Substring(3)
drCurrent.EndEdit()
MsgBox("Record edited successfully")
''END EDIT CODE
现在,我以如下方式实现此代码
now i''m implementing this code in my way as follows
Try
Dim dt As DataTable
Dim dr As DataRow
dt = ds.Tables("Table1")
dr = dt.Rows.Find(Label1.Text)
dr.BeginEdit()
dr("Cust_name") = txtname.Text
dr("Cust_add") = txtadd.Text
dr("Cust_email") = txtemail.Text
dr.EndEdit()
With GridView1
.DataSource = ds.Tables("Table1")
.DataBind()
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
我收到一条错误消息:
i''m getting an error saying:
Object reference not set to an instance of an object.
我可以知道哪里出问题了吗???
may i know where m going wrong..??
这篇关于数据集更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文