473,396 Members | 2,085 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.

Error when filling a datagrid.

Hi,

Im in need of your help once again. I am truing to run a
stored procudure to fill a datagrid. However i keep
encountering the following error:

An unhandled exception of
type 'System.Data.SqlClient.SqlException' occurred in
system.data.dll

Additional information: System error.

the code stope on this line:
da.Fill(ds, "CaraEquip")
here is my full code. can anyone please tell me what im
doin wrong?
Private Sub RBtnEquipYes_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RBtnEquipYes.CheckedChanged

Dim Cn As New SqlConnection("data
source=PARAGLAPTOP\VSdotNET;initial
catalog=CaravanDBLapSQLServ;integrated
security=SSPI;persist security info=False;workstation
id=PARAGLAPTOP;packet size=4096")
Dim cmdCaraEquip As New SqlCommand("SPSelCaraEquip", Cn)
cmdCaraEquip.CommandType =
CommandType.StoredProcedure

cmdCaraEquip.Parameters.Add("@CaraName",SqlDbType. Char, 50)

cmdCaraEquip.Parameters("@CaraName").Value =
CBoxDisCaraNames.SelectedItem

da = New SqlDataAdapter("SPSelCaraEquip", Cn)

ds = New DataSet("CaraEquip")
da.Fill(ds, "CaraEquip")

DataGridEquip.DataSource = ds.Tables(0)

Dim TSCaraEquip As New DataGridTableStyle()
TSCaraEquip.MappingName = "CaraEquip"

Dim TCEquipName As New DataGridTextBoxColumn()
TCEquipName.MappingName = "Equip_Name"
TCEquipName.HeaderText = "Equipment Name"
TCEquipName.Width = 150
TCEquipName.ReadOnly = True
TSCaraEquip.GridColumnStyles.Add(TCEquipName)

DataGridEquip.TableStyles.Add(TSCaraEquip)

DataGridEquip.CaptionText = "Select the meals you wish to
book:"

If RBtnEquipYes.Checked = True Then DataGridEquip.Visible
= True
thx
Nov 22 '05 #1
1 1312
The code appears to set the paramaters for the stored
procedure in the command object and then you pass the name
of the sp to the da. The da has no knowledge of the cmd
object. I think that is your problem.

First, I would put a try catch around the code so that you
don't get an unhandled exception.

Try
... your code
Catch ex as System.Exception
MsgBox(ex.ToString)
End Try

The msgbox will tell you exactly what problem you are
geting.

Hope this helps.

Articles, books, free code, add-ins, general .NET help at
http://www.knowdotnet.com
-----Original Message-----
Hi,

Im in need of your help once again. I am truing to run a
stored procudure to fill a datagrid. However i keep
encountering the following error:

An unhandled exception of
type 'System.Data.SqlClient.SqlException' occurred in
system.data.dll

Additional information: System error.

the code stope on this line:
da.Fill(ds, "CaraEquip")
here is my full code. can anyone please tell me what im
doin wrong?
Private Sub RBtnEquipYes_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RBtnEquipYes.CheckedChanged

Dim Cn As New SqlConnection("data
source=PARAGLAPTOP\VSdotNET;initial
catalog=CaravanDBLapSQLServ;integrated
security=SSPI;persist security info=False;workstation
id=PARAGLAPTOP;packet size=4096")
Dim cmdCaraEquip As New SqlCommand("SPSelCaraEquip", Cn)
cmdCaraEquip.CommandType =
CommandType.StoredProcedure

cmdCaraEquip.Parameters.Add("@CaraName",SqlDbType .Char, 50)
cmdCaraEquip.Parameters("@CaraName").Value =
CBoxDisCaraNames.SelectedItem

da = New SqlDataAdapter("SPSelCaraEquip", Cn)

ds = New DataSet("CaraEquip")
da.Fill(ds, "CaraEquip")

DataGridEquip.DataSource = ds.Tables(0)

Dim TSCaraEquip As New DataGridTableStyle()
TSCaraEquip.MappingName = "CaraEquip"

Dim TCEquipName As New DataGridTextBoxColumn()
TCEquipName.MappingName = "Equip_Name"
TCEquipName.HeaderText = "Equipment Name"
TCEquipName.Width = 150
TCEquipName.ReadOnly = True
TSCaraEquip.GridColumnStyles.Add(TCEquipName)

DataGridEquip.TableStyles.Add(TSCaraEquip)

DataGridEquip.CaptionText = "Select the meals you wish to
book:"

If RBtnEquipYes.Checked = True Then DataGridEquip.Visible
= True
thx
.

Nov 22 '05 #2

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

Similar topics

1
by: Angelina | last post by:
Hi, Im in need of your help once again. I am truing to run a stored procudure to fill a datagrid. However i keep encountering the following error: An unhandled exception of type...
1
by: dbuchanan | last post by:
VB.NET 2003 / SQLS2K The Stored Procedure returns records within Query Analyzer. But when the Stored Procedure is called by ADO.NET ~ it produced the following error message. ...
4
by: starwiz | last post by:
I'm trying to use the DataGrid's editing with a DropDownList. I've tried using every code sample I've seen and none of them seem to be able to solve my problem. When I call...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
1
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). ...
6
by: vips | last post by:
Page_Load datagrid1.datasource=dataset1 //I am filling the datagrid and it works fine when page is displayed end ---------------
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...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
1
by: WayneM | last post by:
I have compact framework app that I was trying to test out on a windows form, but I cannot get past the very first step of simply filling a DataGrid from a DataSet. My code is Dim sqlStmt As...
10
by: Roger | last post by:
ms-access97 & sql server2005 two tables tblItem tblItemFeature form frmItem contains subform frmItemFeature each form is based on their respective table creating new record and filling in...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.