473,395 Members | 1,968 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,395 software developers and data experts.

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 1899
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
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
by: Michelle Keys | last post by:
Subject: DataBinder.Eval Error! Server Error in '/MSPOS' Application. ------------------------------------------------------------------------ -------- DataBinder.Eval:...
0
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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,...
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.