Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET - Unhandled Exception error 1

Status
Not open for further replies.

nplastics

Programmer
Jun 29, 2001
6
US
I have a table with data on our SQL2000 server. I have created a project in VB.NET. I can successfully establish the SqlConnection1, SqlDataAdapter1, and DataSet11. I can preview the data. I then put a DataGrid on the form and connect the DataSource and the proper field headers appear. I then added a "load data" button with the following code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataSet11.Clear()
SqlDataAdapter1.Fill(DataSet11, "customers")

When I run the application and click on the "Load data" button I receive:

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

This has happened with the table/data I created as well as an example with the Northwind database that is on the SQL server.

When I've done the exact same thing with a dummy database I created in Access97 on my hard drive I do not get this error so I assume it is a problem with my connection to the SQL server (?).

Thank you for whatever help you can give.
Deb
 
May want to use a try....catch....end try whenever you are haveing connection errors they will give a bit more insight to the problem


Try
SqlDataAdapter1.Fill(DataSet11, "customers")
catch e as exception
msgbox(e.tostring)
end try



hope that helps

bassguy
 
Thank you Bassguy. Reading the exception in a little more detail did give me a clue as to where the problem was.

My application is now pulling data from the SQL server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top