G
Guest
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("BookingID"), dsFullBooking.Tables("dtCaraBooking").Columns("BookingID"))
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("ClientID")) 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("BookingID")
RoomBookColumns(1) = dsFullBooking.Tables("dtRoomBooking").Columns("RoomID")
RoomBookColumns(2) = dsFullBooking.Tables("dtRoomBooking").Columns("RoomDt")
RoomBookColumns(3) = dsFullBooking.Tables("dtRoomBooking").Columns("Req_Session")
MealBookColumns(0) = dsFullBooking.Tables("dtMealBooking").Columns("BookingID")
MealBookColumns(1) = dsFullBooking.Tables("dtMealBooking").Columns("RoomID")
MealBookColumns(2) = dsFullBooking.Tables("dtMealBooking").Columns("RoomDt")
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
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("BookingID"), dsFullBooking.Tables("dtCaraBooking").Columns("BookingID"))
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("ClientID")) 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("BookingID")
RoomBookColumns(1) = dsFullBooking.Tables("dtRoomBooking").Columns("RoomID")
RoomBookColumns(2) = dsFullBooking.Tables("dtRoomBooking").Columns("RoomDt")
RoomBookColumns(3) = dsFullBooking.Tables("dtRoomBooking").Columns("Req_Session")
MealBookColumns(0) = dsFullBooking.Tables("dtMealBooking").Columns("BookingID")
MealBookColumns(1) = dsFullBooking.Tables("dtMealBooking").Columns("RoomID")
MealBookColumns(2) = dsFullBooking.Tables("dtMealBooking").Columns("RoomDt")
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