473,396 Members | 2,013 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,396 software developers and data experts.

Dataset problems

Hi,

I am trying to create my own dataset and assign it to a
datagrid. However i keep encountering the following
error...

An unhandled exception of
type 'System.NullReferenceException' occurred in
microsoft.visualbasic.dll

Additional information: Object variable or With block
variable not set.

here is my code i am using in the form_load event....

Dim DTable1
DTable1.Columns.Add("Room Date",
Type.GetType("system.datetime"))
DTable1.Columns.Add("Room Name",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Layout",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Session",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Guests",
Type.GetType("system.int32"))
DTable1.Columns.Add("Meal Type",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Quantity",
Type.GetType("system.Int32"))

DataGrid1.DataSource = DTable1
Does anyone know what i am doing wrong??
The application seems to stop in the following line...
DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))
thx in advance
Jul 21 '05 #1
6 5208
Hi Lina,

You are not creating a DataTable instance:
Dim DTable1 As New DTable1()

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Lina" <i@d> wrote in message news:08****************************@phx.gbl...
Hi,

I am trying to create my own dataset and assign it to a
datagrid. However i keep encountering the following
error...

An unhandled exception of
type 'System.NullReferenceException' occurred in
microsoft.visualbasic.dll

Additional information: Object variable or With block
variable not set.

here is my code i am using in the form_load event....

Dim DTable1
DTable1.Columns.Add("Room Date",
Type.GetType("system.datetime"))
DTable1.Columns.Add("Room Name",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Layout",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Session",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Guests",
Type.GetType("system.int32"))
DTable1.Columns.Add("Meal Type",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Quantity",
Type.GetType("system.Int32"))

DataGrid1.DataSource = DTable1
Does anyone know what i am doing wrong??
The application seems to stop in the following line...
DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))
thx in advance

Jul 21 '05 #2
Lina <i@d> wrote:
Does anyone know what i am doing wrong??
The application seems to stop in the following line...
DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))


Type.GetType(string) is case-sensitive. Use "System.DateTime" or
(preferrably) use TypeOf(DateTime).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3
Hi Miha,

I have made the ammended that u suggested. thx for that. I
dont know how i missed it :o)

I am getting another error that i have encountered before
but i did not know how to resolve it. The code stops on
the same line again...

DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))

but this time i am getting the following error:

An unhandled exception of
type 'System.ArgumentNullException' occured in
system.data.dll

Additional information: 'dataType' argument cannot be
null.

Do u know what this is? I have not created any primary
keys on this datatable so i do not know why the coloumn
cannot be null when it is first created and loaded into my
datagrid!!

thx

-----Original Message-----
Hi Lina,

You are not creating a DataTable instance:
Dim DTable1 As New DTable1()

--
Miha Markic - RightHand .NET consulting & software developmentmiha at rthand com
www.rthand.com

"Lina" <i@d> wrote in message news:082201c3d914$07181d20

$a*******@phx.gbl...
Hi,

I am trying to create my own dataset and assign it to a
datagrid. However i keep encountering the following
error...

An unhandled exception of
type 'System.NullReferenceException' occurred in
microsoft.visualbasic.dll

Additional information: Object variable or With block
variable not set.

here is my code i am using in the form_load event....

Dim DTable1
DTable1.Columns.Add("Room Date",
Type.GetType("system.datetime"))
DTable1.Columns.Add("Room Name",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Layout",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Session",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Guests",
Type.GetType("system.int32"))
DTable1.Columns.Add("Meal Type",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Quantity",
Type.GetType("system.Int32"))

DataGrid1.DataSource = DTable1
Does anyone know what i am doing wrong??
The application seems to stop in the following line...
DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))
thx in advance

.

Jul 21 '05 #4
Hi Lina,

I guess Jon had a vision and already responded to your question before
you've even posted.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Lina" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Hi Miha,

I have made the ammended that u suggested. thx for that. I
dont know how i missed it :o)

I am getting another error that i have encountered before
but i did not know how to resolve it. The code stops on
the same line again...

DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))

but this time i am getting the following error:

An unhandled exception of
type 'System.ArgumentNullException' occured in
system.data.dll

Additional information: 'dataType' argument cannot be
null.

Do u know what this is? I have not created any primary
keys on this datatable so i do not know why the coloumn
cannot be null when it is first created and loaded into my
datagrid!!

thx

-----Original Message-----
Hi Lina,

You are not creating a DataTable instance:
Dim DTable1 As New DTable1()

--
Miha Markic - RightHand .NET consulting & software

development
miha at rthand com
www.rthand.com

"Lina" <i@d> wrote in message news:082201c3d914$07181d20

$a*******@phx.gbl...
Hi,

I am trying to create my own dataset and assign it to a
datagrid. However i keep encountering the following
error...

An unhandled exception of
type 'System.NullReferenceException' occurred in
microsoft.visualbasic.dll

Additional information: Object variable or With block
variable not set.

here is my code i am using in the form_load event....

Dim DTable1
DTable1.Columns.Add("Room Date",
Type.GetType("system.datetime"))
DTable1.Columns.Add("Room Name",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Layout",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Session",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Guests",
Type.GetType("system.int32"))
DTable1.Columns.Add("Meal Type",
Type.GetType("system.varchar"))
DTable1.Columns.Add("Quantity",
Type.GetType("system.Int32"))

DataGrid1.DataSource = DTable1
Does anyone know what i am doing wrong??
The application seems to stop in the following line...
DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))
thx in advance

.

Jul 21 '05 #5
Thx Jon

The application no longer falls over on loading but the
datagrid still does not display any of the coloumn
headings i created for my empty dataTable!!!

i have used this line after craeting my dataTable...

DataGrid1.DataSource = DTable1

is this correct for making the coloumns i created to be
displayed or do i require more code?

Sorry for the many questions i ask. I am very new to VB.NET
:o)
Is this normally the case?
-----Original Message-----
Lina <i@d> wrote:
Does anyone know what i am doing wrong??
The application seems to stop in the following line...
DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))
Type.GetType(string) is case-sensitive.

Use "System.DateTime" or(preferrably) use TypeOf(DateTime).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Jul 21 '05 #6
Hi Miha and Jon,

thx for taking the time to help me. I have just managed to
get the problem resolved with your help.

:o)
-----Original Message-----
Thx Jon

The application no longer falls over on loading but the
datagrid still does not display any of the coloumn
headings i created for my empty dataTable!!!

i have used this line after craeting my dataTable...

DataGrid1.DataSource = DTable1

is this correct for making the coloumns i created to be
displayed or do i require more code?

Sorry for the many questions i ask. I am very new to VB.NET:o)
Is this normally the case?
-----Original Message-----
Lina <i@d> wrote:
Does anyone know what i am doing wrong??
The application seems to stop in the following line...
DTable1.Columns.Add("Room Date", Type.GetType
("system.datetime"))


Type.GetType(string) is case-sensitive.

Use "System.DateTime" or
(preferrably) use TypeOf(DateTime).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

.

Jul 21 '05 #7

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

Similar topics

4
by: Joerg M. Colberg | last post by:
Hi all, I have a problem when using a DataSet. I am using it to query a SQLServer database as follows. In my code it looks like SqlDataAdapter eDA = new SqlDataAdapter(sqlcmd); // where...
2
by: Dennis | last post by:
Hi, I am hoping I can get some help with a small problem I have run into using C#. U have an XML file that I load into a Dataset and then display this in a Datagrid. No problems doing this at all....
5
by: Roy Lawson | last post by:
I am having no problems connecting to a DB, creating a DataAdapter, and creating a dataset...and connecting to the data. Using the builtin data objects to do all this. My only problem now is...
3
by: Anthony | last post by:
Hi There When trying to add a dataset to a web form I get the following error msg. "There were problems generating . To resolve this problem build the project, fix the errors and generate...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
4
by: Opa Vito | last post by:
Hello, I can't find out if a DataSet (and/or datatable) can be declared public so the xml data can be read to the DataSet in the form load, and then can be acessed from whatever sub or function...
0
by: ~J~ | last post by:
Hi, I really hope someone can help me out here. In relation to this thread ( http://www.thescripts.com/forum/thread349557.html ) I'm having a similar issue and getting nowhere fast! In a...
2
by: Magnus Bergh | last post by:
I got a weird problem with designer. I have created a spearate assembly (DLL) containing my dataset classes and other classes which are shared bewteen the projects in the solution. When I try to...
12
by: Rainer Queck | last post by:
Hi NG, I have no idea why, but since a while a dataset refuses to write to a specific xml file. I get the error message "Der Zugriff auf den Pfad...
4
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.