Error with SqlDataAdapter in Fill Method

P

Philip Tepedino

Hi all,

I'm getting an error when my class calls the
SqlDataAdapte.Fill(SomeDataSet)

I have a SqlCommand object with a valid query and
connection (this part works), I then set the
SqlDataAdapter's SelectCommand = SqlCommand.
I make a new DataSet such as: Dim SomeDataSet as DataSet =
New Dataset, then call the .Fill


The error is as follows:

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

Additional information: System error.

I've looked online for help, but can't seem to find
anything specific. Any help would be greatly appreciated.

Thanks,

Philip Tepedino
(e-mail address removed)
Database/Software Development
Siemens Westinghouse Generation Services
 
W

William Ryan

Philip:

It could be many things. The most likely culprit is the connection, make
sure you can open it (I know you saidthis part works, but I'm not sure how
far you went with it). I'd wrap my Fill command in a try catch block and
then see what Exception.ToSTring yeilds. Fill is kind of tricky b/c the
DataAdapter opens and closes the connection for you, so you could get an
exception with that, or with the execution of the command due to
permissions, syntax errors etc.

As such, I'd try opening the connection before the fill just for testing
purposes, in real life, the the DataAdapter do its job. It's kind of hard
to tell from just this, but if you could post the whole snippet, I'm sure we
can figure it out.

Cheers,

Bill

Try
da.Fill(myDataSet)
catch sq as SqlException 'Or OleDBException
Debug.Assert(false, sq.ToString)'See if it's database related
catch ex as System.Exception
debug.Assert(false, ex.ToString) 'Null references and everything else.

This should help narrow it down.

Cheers,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top