####错误将行插入数据表 [英] #### error inserting a row into a datatable

查看:91
本文介绍了####错误将行插入数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




当我点击按钮时,我试图在我的数据集中插入一个新行。这是我的代码


Dim ClientInsRow As DataRow = dtClient.NewRo


ClientInsRow(" Surname")= txtSurname.Tex
ClientInsRow(" Forename")= txtForename.Tex

ClientInsRow(" OrgName")= txtOrganisation.Tex

ClientInsRow(" Address") = txtAddress.Tex

ClientInsRow(" Postcode")= txtPostcode.Tex

ClientInsRow(" PhoneNo")= txtPhoneNo.Tex


''通过调用DataRowCollection对象的Add方法将新记录添加到表中。

dtClient.Rows.Add(ClientInsRow


i继续收到一条消息,说明......

''名称dtClient未被宣布


我做错了什么?我跟着这个例子来自vb.net帮助文件!

我在form_Load事件中创建了包含5个数据表和4个数据的数据集


任何人都可以帮助我?

Hi

i am trying to insert a new row into one of my datatabels that i have in my dataset when a button is clicked. here is my code

Dim ClientInsRow As DataRow = dtClient.NewRo

ClientInsRow("Surname") = txtSurname.Tex
ClientInsRow("Forename") = txtForename.Tex
ClientInsRow("OrgName") = txtOrganisation.Tex
ClientInsRow("Address") = txtAddress.Tex
ClientInsRow("Postcode") = txtPostcode.Tex
ClientInsRow("PhoneNo") = txtPhoneNo.Tex

''Add the new record to the table by calling the Add method of the DataRowCollection object.
dtClient.Rows.Add(ClientInsRow

i keep getting a message stating that....
''name dtClient is not declared

what am i doin wrong? i have followed the example from the vb.net help files!

My dataset with 5 datatables and 4 datarelations is created in the form_Load event

Can anyone help me??

推荐答案

嗨玉(伊娃),


这只是测试你使用了多少个名字。


但是对我而言,它并没有贬值,


尝试在您的表单中将您的数据集设为私有

将它放在行窗口下方窗体设计师

私有dsFullBooking作为新数据集


...
Hi Jade (Eva),

It was just a test how many names you use.

But for me it does not botter,

Try to make your dataset private in your form
Put it beneath the row windows form designer
Private dsFullBooking as new dataset

...
Dim dsFullBooking As New DataSet(
并删除上面的行,

这不是最好的,但首先让它工作。

''创建客户数据表
da = New SqlDataAdapter(" SELECT * FROM Client",Cn)
''da.Fill(dsFullBooking," dtClient")
da.FillSchema(dsFullBooking,SchemaType.Mapped," dtClient")
Dim dsFullBooking As New DataSet( and than delete the row above,
It is not the nicest but first get it working.
''create the customer datatable
da = New SqlDataAdapter("SELECT * FROM Client", Cn)
''da.Fill(dsFullBooking, "dtClient")
da.FillSchema(dsFullBooking, SchemaType.Mapped, "dtClient")



我认为会解决这个问题吗?


:-)

Cor


I think that will resolve this?

:-)

Cor


Hi Eva


您是否尝试过使用
Hi Eva

Did you try it with something as
Dim ClientInsRow As DataRow =
dsFullBooking.tables(" dtClient")。NewRow
ClientInsRow(" Surname")= txtSurname.Text
ClientInsRow(" Forename" ;)= txtForename.Text
ClientInsRow(" OrgName")= txtOrganisation.Text
ClientInsRow(" Address")= txtAddress.Text
ClientInsRow(" Postcode")= txtPostcode。文本
ClientInsRow(" PhoneNo")= txtPhoneNo.Text

dsFullBooking.tables(" dtClient")。Rows.Add(ClientIn sRow)
Dim ClientInsRow As DataRow = dsFullBooking.tables("dtClient").NewRow
ClientInsRow("Surname") = txtSurname.Text
ClientInsRow("Forename") = txtForename.Text
ClientInsRow("OrgName") = txtOrganisation.Text
ClientInsRow("Address") = txtAddress.Text
ClientInsRow("Postcode") = txtPostcode.Text
ClientInsRow("PhoneNo") = txtPhoneNo.Text
dsFullBooking.tables("dtClient").Rows.Add(ClientIn sRow)




Cor



Cor


hi cor


我已经尝试了你的代码,现在我得到一条消息说明。 ....

名称''dsFullBooking''未宣布


我不知道为什么我得到这个,因为我已经宣布代码进一步向上form_load事件。

Dim dsFullBooking作为新数据集(

''创建客户数据表

da =新SqlDataAdapter(" SELECT * FROM Client",Cn

''da.Fill(dsFullBooking) ,dtClient

da.FillSchema(dsFullBooking,SchemaType.Mapped," dtClient"


你知道如何解决这个问题吗? />
hi cor

I have tried your code and now im gettin a message stating.....
Name ''dsFullBooking'' is not declared

I dont know why i am getting this as i have declared the code further up oin the form_load event.
Dim dsFullBooking As New DataSet(
''create the customer datatabl
da = New SqlDataAdapter("SELECT * FROM Client", Cn
''da.Fill(dsFullBooking, "dtClient"
da.FillSchema(dsFullBooking, SchemaType.Mapped, "dtClient"

do u have any idea how to resolve this


这篇关于####错误将行插入数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆