How to MANUALLY create a TableAdapter


Hi,

I use a VB.NET application that connects to a Web Service I made.

The Web Service is responsible to collect data from an Online database and send it to the Windows application. It's also responsible to GET new data from the application and Update the Online database.

The Web Service works fine. My question is in the application. I created a Dataset that GETS a dataset from the Web Service. Now I want to USE that data in the application. I am having trouble with both DataRow and TableAdapter. (I don't want to add any DataSource in my application, so I can't use any wizards.

1. I can't create a NEW DataRow. I get the following error:

Dim dr As New DataRow (It tells me that it is not accessible in this context because it is protected)

2. I can't create a TableAdapter. Just can't find it in the toolbox and it's not an option in the VS drop-down when I do Dim ta As New... So How can I get data from the DataSet into a DataRow? (I know we must have an Adpter because the DataSet doesn't have references to the data points.)

Thank you

[1107 byte] By [Zvi_T] at [2007-12-25]
# 1

Hi,

' How to create a table row

'sample table

Dim tb As New Data.DataTable()

' Create and add column to sample table

Dim cl1 As New DataColumn("Col One")

cl1.DataType = String.Empty.GetType()

tb.Columns.Add(cl1)

' Get new row object as for table schema (apporpriate columns etc)

' Must use target table to get row object

Dim rw As DataRow = tb.NewRow()

' Set row value

rw.Item("Col One") = System.DateTime.Now.ToShortDateString()

' add new row to table

tb.Rows.Add(rw)

Does this help?

Rgds,

Martin.

mokeefe at 2007-9-3 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 2

Yes! Thank you so much!

Zvi_T at 2007-9-3 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...