473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

error message with datatable

Eva
Hi,

I am creating 2 datatables and am joining them via a
relationship i have created. I want to create a parent
child relationship in a datagrid (If this is possible???).

However i keep encountering the following error...
An unhandled exception of
type 'System.NullReferenceException' occurred in
Caravan.exe

Additional information: Object reference not set to an
instance of an object.

here is my code.....
'create empty dataset here so that the meal and room
bookings can be written to this before being pushed to
the database
Dim dataset1 As New DataSet()

Dim DataTable1 As New DataTable()
DataTable1 .Columns.Add("BookingNo", Type.GetType
("System.Int32"))
DataTable1 .Columns.Add("RoomID", Type.GetType
("System.Char"))
DataTable1 .Columns.Add("Room Date", Type.GetType
("System.DateTime"))
DataTable1 .Columns.Add("Req. Session",
Type.GetType("System.Char"))
DataTable1 .Columns.Add("Req. Layout",
Type.GetType("System.Char"))
DataTable1 .Columns.Add("Guests", Type.GetType
("System.Int32"))

'create the meal booking data table
Dim DataTable2 As New DataTable()
DataTable2.Columns.Add("BookingNo", Type.GetType
("System.Int32"))
DataTable2.Columns.Add("RoomID", Type.GetType
("System.Char"))
DataTable2.Columns.Add("RoomDt", Type.GetType
("System.DateTime"))
DataTable2.Columns.Add("Req. Session",
Type.GetType("System.Char"))
DataTable2.Columns.Add("Meal Type",
Type.GetType("System.Char"))
DataTable2.Columns.Add("Quantity", Type.GetType
("System.Int32"))

'add both tables into the dataset
dataset1 .Tables.Add(DataTable1)
dataset1 .Tables.Add(DataTable2)
'create a relationship between the two data tables
Dim ParentArray(4) As DataColumn
ParentArray(0) = dataset1.Tables
("DataTable1").Columns("BookingNo")
ParentArray(1) = dataset1.Tables
("DataTable1").Columns("RoomID")
ParentArray(2) = dataset1.Tables
("DataTable1").Columns("RoomDt")
ParentArray(3) = dataset1.Tables
("DataTable1").Columns("Req. Session")

Dim ChildArray(4) As DataColumn
ChildArray(0) = dataset1.Tables
("DataTable2").Columns("BookingNo")
ChildArray(1) = dataset1.Tables
("DataTable2").Columns("RoomID")
ChildArray(2) = dataset1.Tables
("DataTable2").Columns("RoomDt")
ChildArray(3) = dataset1.Tables
("DataTable2").Columns("Req. Session")

Dim relRoomToMealBooking As New DataRelation
("relRoomToMealBooking", ParentArray, ChildArray)
dataset1.Relations.Add(relRoomToMealBooking)

DataGrid1.DataSource = dataset1

Can anyone see what i am doin wrong??
The application seems to stop at this line...

ParentArray(0) = dsRoomMealBookingDisp.Tables
("DTableRoomBooking").Columns("BookingNo")
thx
Jul 21 '05 #1
0 872

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tshad | last post by:
I am getting the error: **************************************************************************** Array does not have that many dimensions. Description: An unhandled exception occurred during...
1
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to...
7
by: scorpion53061 | last post by:
This exception occured while running in the development environment. The debugger didnt catch it though it appeared as a message box prompt........does anyone have insight on this? ...
9
by: whaletyr | last post by:
When I try to update an access database using the commandbuilder and updatecommand. I get the An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll ...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
7
by: deltalimagolf | last post by:
I now get the following error message after copying an asp.net application to the deployment web server. I don't have SQLExpress or any version of SQL 2005 installed. I found the "LocalSQLServer"...
0
by: Danny | last post by:
Hi, we just have launched our first beta version of our new product page which was developed with ASP.NET. Now we noticed that we sometimes get the error attached below. After a little web...
1
by: Danny | last post by:
Hi guys, I sometimes get the following error on my ASP.NET webpage. Server Error in '/' Application. -------------------------------------------------------------------------------- ...
1
by: =?Utf-8?B?SmFjaw==?= | last post by:
Hi, I have a simple code where I am trying to capture a recordset in a grid veiw using a button click event. Data is connected to sql server 2000. However, I am getting error at the line...
6
by: fniles | last post by:
I am using VB.NET 2005 and Access database. My program uses a timer that kicks in every 1 min to read from a database and copy the dataset table to a datatable. This database is in a class called...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.