473,511 Members | 17,486 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error with datagrid

hi,

I am trying to setup a datagrid that pulls values from a
database but i keep getting an error message when i run
the application. Can anyone help me??
The application stops at the line:
da2.fill(ds2)

i keep getting the following error message:

An unhandled exception of
type 'System.Data.SqlClient.SqlException' occurred in
system.data.dll
here is my code leading up to this:

da2 = New SqlDataAdapter("SELECT Meal_Desc, 0 as Quantity
FROM Equipment_Details", Cn)

ds2 = New DataSet("MealBooking")
da2.Fill(ds2)

DGridMealBooking.DataSource = ds2.Tables(0)
this code is in the form_load event.
I have another datagrid being filled just above this one
shown above.

I have instantiated outside of the form load as:
Private da2 as SqlDataAdapter
Private ds2 as dataset

Can anyone help? i have no idea what i have done wrong!!

thx
Nov 22 '05 #1
2 1901
The SQLException doesn't have anything to do with the grid. First make sure
you have a good connection/connectionstring. Then make sure you can run the
query in QA b/c if you have a bad query, it's going to blow up on you..

My guess is that's it's your query, but I'd check the connection too. You
can try just for testing, YourConnection.Open right before the Da.Fill and
make sure it doesn't throw an exception. If it works, it's probably that 0
as a column name.

HTH,

Bill
"Tonya" <s@dis> wrote in message
news:1e****************************@phx.gbl...
hi,

I am trying to setup a datagrid that pulls values from a
database but i keep getting an error message when i run
the application. Can anyone help me??
The application stops at the line:
da2.fill(ds2)

i keep getting the following error message:

An unhandled exception of
type 'System.Data.SqlClient.SqlException' occurred in
system.data.dll
here is my code leading up to this:

da2 = New SqlDataAdapter("SELECT Meal_Desc, 0 as Quantity
FROM Equipment_Details", Cn)

ds2 = New DataSet("MealBooking")
da2.Fill(ds2)

DGridMealBooking.DataSource = ds2.Tables(0)
this code is in the form_load event.
I have another datagrid being filled just above this one
shown above.

I have instantiated outside of the form load as:
Private da2 as SqlDataAdapter
Private ds2 as dataset

Can anyone help? i have no idea what i have done wrong!!

thx

Nov 22 '05 #2
The SQLException doesn't have anything to do with the grid. First make sure
you have a good connection/connectionstring. Then make sure you can run the
query in QA b/c if you have a bad query, it's going to blow up on you..

My guess is that's it's your query, but I'd check the connection too. You
can try just for testing, YourConnection.Open right before the Da.Fill and
make sure it doesn't throw an exception. If it works, it's probably that 0
as a column name.

HTH,

Bill
"Tonya" <s@dis> wrote in message
news:1e****************************@phx.gbl...
hi,

I am trying to setup a datagrid that pulls values from a
database but i keep getting an error message when i run
the application. Can anyone help me??
The application stops at the line:
da2.fill(ds2)

i keep getting the following error message:

An unhandled exception of
type 'System.Data.SqlClient.SqlException' occurred in
system.data.dll
here is my code leading up to this:

da2 = New SqlDataAdapter("SELECT Meal_Desc, 0 as Quantity
FROM Equipment_Details", Cn)

ds2 = New DataSet("MealBooking")
da2.Fill(ds2)

DGridMealBooking.DataSource = ds2.Tables(0)
this code is in the form_load event.
I have another datagrid being filled just above this one
shown above.

I have instantiated outside of the form load as:
Private da2 as SqlDataAdapter
Private ds2 as dataset

Can anyone help? i have no idea what i have done wrong!!

thx

Nov 22 '05 #3

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

Similar topics

1
2224
by: Mad Scientist Jr | last post by:
I am getting an error in my code that references a textbox inside the current row of my datagrid, whenever I try changing the page (paging is enabled). This code doesn't even run unless a button in...
0
3803
by: Michelle Keys | last post by:
Subject: DataBinder.Eval Error! Server Error in '/MSPOS' Application. ------------------------------------------------------------------------ -------- DataBinder.Eval:...
0
2117
by: Roman | last post by:
I'm trying to create the form which would allow data entry to the Client table, as well as modification and deletion of existing data rows. For some reason the DataGrid part of functionality stops...
6
1733
by: Teep | last post by:
Below is my code for dropdownlist that is populated from a SQL table. After a selection from the ddl, a datagrid is suppose to come up pertaining to the information selected, but I keep getting a...
2
2112
by: david | last post by:
Problem: There is a search button, Search, in form, for searching patient info list. The error occurs after the following steps: 1. search first time is OK, and all found the records are...
17
2730
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
8
2456
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!!...
1
1678
by: Paulustrious | last post by:
Newbie using VC# Express..... Part the First ======== Can some one tell me why Example 1 compiles and Example 2 does not... Example 1 ------------ using System;
25
4350
by: Blasting Cap | last post by:
I keep getting errors that pop up when I am trying to convert an application from dotnet framework 1.1 to framework 2.0. The old project was saved in sourcesafe from Visual Studio 2003, and I have...
0
1067
by: prerak_v_shah | last post by:
Hi, Friends, I have been developing datagrid program in .Net 1.1 and having VB.Net as a programming language. I have created a datagrid which is bound to a datatable as its datasource. It also...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7356
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
7512
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...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.