Accessing dataset datatable table row problem

Accessing dataset datatable table row problem

Post by Tony Girge » Tue, 19 Sep 2006 01:08:27


Hello

I developed and tested a web application using VS.NET 2003, VB, .NET
Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form.

I used the XML Designer to create an XML .XSD Schema to produce a Dataset.

In looking for a way to start adding data to the dataset programmatically, i
found this method in just about every thing i read.

Dim tripsDataSet As DataSet
tripsDataSet = New DataSet("tripsDS")
tripsDataSet.ReadXmlSchema("c:\inetpub\wwwroot\CoyneTruckWebServices\tripsds.xsd")
tripsDataTbl = tripsDataSet.Tables("tripsTable")
Dim foundTrips() As DataRow

When i try to enter an assignment as below, the IDE will not give me the
intellisense "NewRow()" at the end of the "foundTrips = tripsDataTbl"
statement. It only give me a "GetType".

foundTrips = tripsDataTbl.NewRow()

I i run the program anyway, It bombs out with "No default member found for
type 'DBNull'" on this line

foundTrips(tripidx)("TripDate") = dateAttr.ToString("yyyyMMdd").

dateAttr does have something in it.

How do i get this to work ? I've been trying to figure this out for days.

Any help would be gratefully appreciated.

Thanks,
Tony
 
 
 

Accessing dataset datatable table row problem

Post by Gregory A. » Tue, 19 Sep 2006 03:14:30

If you have created a DataSet, you should have a class already defined. You
will instantiate that class, not DataSet. For example, you add a DataSet
called CustomersDS. The line would be:

Dim custDS as New CustomersDS()

If you are doing this on the fly, at runtime (ala the example you gave), you
will NOT have intellisense, as something created at runtime is not available
at design time.

Once you instantiate as a strongly typed dataset, you should be in good
shape. The type of row you will want to add, however, is of the type of the
name of the table and you will pull it from the methods in the strongly
typed dataset instead of a generic new row.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************

 
 
 

Accessing dataset datatable table row problem

Post by Tony Girge » Tue, 19 Sep 2006 13:16:30

K. Now i have it like this:

Dim tripsDataSet As New tripsDS
Dim tripsDataTbl As New tripsDS.tripsTableDataTable
tripsDataSet.ReadXmlSchema("c:\inetpub\wwwroot\CoyneTruckWebServices\tripsds.xsd")
Dim foundTrips As DataRow
foundTrips = tripsDataTbl.NewRow

When i run it, it blows up on the ReadXmlSchema line with " Invalid 'Key'
node inside constraint named: tripsTableRel".

I'm not sure i follow what you are trying to explain to me.

will NOT have intellisense, as something created at runtime is not available
at design time <<

Is there another way to do this if not at run time ?

name of the table and you will pull it from the methods in the strongly
typed dataset instead of a generic new row <<

The table i defined has a row type ?

I hope you don't mind me asking so many questions. It's just that i am
trying to learn this new technology and i spend days on trying to resolve
problems by researching and reading. My posts here usually come after that
and when i get a reply, i try to seize the opportunity to learn as much as i
can from a knowledgeable individual such as yourself.

Thanks,
Tony

"Cowboy (Gregory A. Beamer)" < XXXX@XXXXX.COM > wrote in
message news: XXXX@XXXXX.COM ...