By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,117 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,117 IT Pros & Developers. It's quick & easy.

Error creating a dataset

P: n/a
Hi, I am trying to create a dataset with 6 tables and 5 relationships created between them. I am creating it in the Form_Load event. However i keep getting the following error...

An unhandled exception of type 'System.ArgumentNullException' occurred in system.data.dll
Additional information: 'column' argument cannot be null.

The code stops on this line...
Dim rel_Booking_CaraBook As New DataRelation("dsFullBooking", dsFullBooking.Tables("dtBooking").Columns("Booking ID"), dsFullBooking.Tables("dtCaraBooking").Columns("Boo kingID"))

Does anyone know what im doin wrong??
Here is my full code....

Dim dsFullBooking As New DataSet()
'create the customer datatable
da = New SqlDataAdapter("SELECT * FROM Client", Cn)
da.Fill(dsFullBooking, "dtClient")
'create the booking datatable
da = New SqlDataAdapter("SELECT * FROM Booking", Cn)
da.Fill(dsFullBooking, "dtBooking")
'create the Caravan_Booking datatable
da = New SqlDataAdapter("SELECT * FROM Caravan_Booking", Cn)
da.Fill(dsFullBooking, "dtCaraBooking")
'create the Room_booking datatable
da = New SqlDataAdapter("SELECT * FROM Room_Booking", Cn)
da.Fill(dsFullBooking, "dtRoomBooking")
'create the Meal_Booking datatable
da = New SqlDataAdapter("SELECT * FROM Meal_Bookings", Cn)
da.Fill(dsFullBooking, "dtMealBooking")

'----------Relationships
Dim rel_Client_Booking As New DataRelation("dsFullBooking", dsFullBooking.Tables
("dtClient").Columns("ClientID"), dsFullBooking.Tables("dtBooking").Columns("ClientI D")) dsFullBooking.Relations.Add(rel_Client_Booking)

Dim rel_Booking_CaraBook As New DataRelation("dsFullBooking", dsFullBooking.Tables
("dtBooking").Columns("BookingID"), dsFullBooking.Tables("dtCaraBooking").Columns
("BookingID"))
dsFullBooking.Relations.Add(rel_Booking_CaraBook)
Dim rel_Booking_RoomBook As New DataRelation("dsFullBooking", dsFullBooking.Tables
("dtBooking").Columns("BookingID"), dsFullBooking.Tables("dtRoomBooking").Columns
("BookingID"))

dsFullBooking.Relations.Add(rel_Booking_RoomBook)

'Declare the Columns for the datarelation (for compound keys)
Dim RoomBookColumns(4) As DataColumn
Dim MealBookColumns(4) As DataColumn

RoomBookColumns(0) = dsFullBooking.Tables("dtRoomBooking").Columns("Boo kingID")
RoomBookColumns(1) = dsFullBooking.Tables("dtRoomBooking").Columns("Roo mID")
RoomBookColumns(2) = dsFullBooking.Tables("dtRoomBooking").Columns("Roo mDt")
RoomBookColumns(3) = dsFullBooking.Tables("dtRoomBooking").Columns("Req _Session")

MealBookColumns(0) = dsFullBooking.Tables("dtMealBooking").Columns("Boo kingID")
MealBookColumns(1) = dsFullBooking.Tables("dtMealBooking").Columns("Roo mID")
MealBookColumns(2) = dsFullBooking.Tables("dtMealBooking").Columns("Roo mDt")
MealBookColumns(3) = dsFullBooking.Tables("dtMealBooking").Columns("Req _Session")

Dim rel_RoomBook_MealBook As New DataRelation("myRelationName", RoomBookColumns,
MealBookColumns, True)
dsFullBooking.Relations.Add(rel_RoomBook_MealBook)
any help is appreciated

Jul 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Cor
Hi Jade,

Did you check all the names like BookingID with me this is mostly a case
error that I did make.

VB is in this case also case sensetive

Cor
Jul 21 '05 #2

P: n/a
Hi Cor

I have checked all the coloumn names and they all match up to what is in my database!
What i wasnt sure about is if i need to use the SQLDataReader to place a single value into a textbox. Is this the easiest/best way to do this?

This is the code i found on the net to add values to a combobox. I modified it for my purposes

Is it correct?
Jul 21 '05 #3

P: n/a
Hi Cor,

I have checked all the column headings and they are correct!!!
Is my syntax correct? I used a web example to get this code which i tailored to my own needs.

btw, do not read my post below this as i posted here by accident. :o)
Jul 21 '05 #4

P: n/a
Cor
Hi Jade,

For me it becomes also guessing now, but I see you did give all your
datarelations the name
"dsFullBooking" maybe if you give them an unique name (that is as I use it)

Cor

">
I have checked all the column headings and they are correct!!!
Is my syntax correct? I used a web example to get this code which i

tailored to my own needs.
Jul 21 '05 #5

P: n/a
Hi Cor

I have elimated many of the errors i have and i am on the last part of my code now. :o

I am getting the following error..
An unhandled exception of type 'System.ArgumentNullException' occurred in system.data.dl
Additional information: 'column' argument cannot be null

the code stops at this line...
Dim rel_RoomBook_MealBook As New DataRelation("rel_RoomBook_MealBook",
RoomBookColumns, MealBookColumns, True

the code for this relationship is listed below. This relationship is coded differently to the other as both relations contain a compound key.
do u know what this message concerns?? could it be anything to do with the fact that the meal_Booking table in my database does not contain any data therefore it has nothing to join with on the room_bookings table??? Can the data affect this

'Declare the Columns for the datarelation (for compound keys
Dim RoomBookColumns(4) As DataColum
Dim MealBookColumns(4) As DataColum

RoomBookColumns(0) = dsFullBooking.Tables("dtRoomBooking").Columns("Boo kingNo"
RoomBookColumns(1) = dsFullBooking.Tables("dtRoomBooking").Columns("Roo mID"
RoomBookColumns(2) = dsFullBooking.Tables("dtRoomBooking").Columns("Roo mDt"
RoomBookColumns(3) = dsFullBooking.Tables("dtRoomBooking").Columns("Req _Session"

MealBookColumns(0) = dsFullBooking.Tables("dtMealBooking").Columns("Boo kingNo"
MealBookColumns(1) = dsFullBooking.Tables("dtMealBooking").Columns("Roo mID"
MealBookColumns(2) = dsFullBooking.Tables("dtMealBooking").Columns("Roo mDt"
MealBookColumns(3) = dsFullBooking.Tables("dtMealBooking").Columns("Req _Session"

'Add the name and DataColumn arrays to the Relatio
Dim rel_RoomBook_MealBook As New DataRelation("rel_RoomBook_MealBook",
RoomBookColumns, MealBookColumns, True
'Add the Relation to the DataSe
dsFullBooking.Relations.Add(rel_RoomBook_MealBook)
Jul 21 '05 #6

P: n/a
Cor
Hi Jade,
the code for this relationship is listed below. This relationship is coded differently to the other as both relations contain a compound key. do u know what this message concerns?? could it be anything to do with the

fact that the meal_Booking table in my database does not contain any data
therefore it has nothing to join with on the room_bookings table??? Can the
data affect this?

I thik you are right

I would try what the fillschema could do for me

http://msdn.microsoft.com/library/de...chematopic.asp

you have than an empty dataset with a good schema

Cor


Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.