Error with dataAdapter.fill

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

i amtrying to create a datatable with numerous tables in it. I have created each datatable in turn and then coded all the reltionships between them after. However when i run the application i get the following error message:

An unhandled exception of type 'System.ArgumentNullException' occurred in system.data.dl
Additional information: Value cannot be null

does anyone know what this may be regarding? Im stumped!! :o
Im not to sure what i have done wrong as i am using examples from a book

This is how i have done my coding
Private da As SqlDataAdapte
Private ds As DataSe

da = New SqlDataAdapter("SELECT * FROM Room_Details", Conn
da.Fill(ds, "dtRoom_Details"

Thx
 
Hi,

You are passing a uninitialized dataset (ds) to Fill method.
Private ds As New DataSet should be better.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Bhavna said:
Hi,

i amtrying to create a datatable with numerous tables in it. I have
created each datatable in turn and then coded all the reltionships between
them after. However when i run the application i get the following error
message:
 
Hi Miha

thx for that. Now the first and second datatable code runs ok. I get a error message on the dataRelations creation

An unhandled exception of type 'System.ArgumentException' occurred in system.data.dl
Additional information: These columns don't currently have unique values

For this i am trying to create a relationship between 'dtCaravan_Details' and 'dtCaravan_Inv'
They are both joined via 'Caravan_Model
dtCaravan_Details is the parent table and has 2 columns as it primary key 'Caravan_Model' and 'Length
dtCaravan_Inv is the child table and just has one key attribute 'Caravan_Model

I have created my code like so. Can u see anything wrong with this

Dim rel_CaraDet_CaraInv As New DataRelation("rel_CaraDet_CaraInv", ds.Tables("dtCaravan_Details").Columns("Caravan_Model"), ds.Tables("dtCaravan_Inv").Columns("Caravan_Model")

ds.Relations.Add(rel_CaraDet_CaraInv

Do i need to only include the joining column in the datarelation or do i include the primary keys of both tables into the datarelation

Can the data contained in the database be causing a problem

Thx Mih
 
Hello Miha,

I hav just solved the above problem. I made a few silly spelling mistakes in my SQL!!

Thx for pointing out my error prior to this
 
Back
Top