DataSet problem

J

Joerg M. Colberg

Hi all,

I have a problem when using a DataSet. I am using it to query a
SQLServer database as follows. In my code it looks like

SqlDataAdapter eDA = new SqlDataAdapter(sqlcmd);
// where sqlcmd is a SQL String
DataSet ds = new DataSet();
eDA.fill(ds);

So far so good. That runs without any problems and I can get
the data out of the DataSet ds without any problems. But later in the
same code, I want to re-use ds. Thing is I get so much data back from
the database that if I write

eDA = new SqlDataAdapter(sqlcmd2);
// where sqlcmd2 is a different SQL String
DataSet ds2 = new DataSet();
eDA.fill(ds2);

the code just stops. It doesn't give me any error messages and if
I put a try-catch block around "eDA.fill(ds2);" there's nothing to
be caught. So I wanted to use something like

ds.Clear();

to empty ds and then re-fill it with different data:

eDA = new SqlDataAdapter(sqlcmd2);
eDA.Fill(ds);

but that won't work. I put some console output around the last line
and that line just never comes back (I ran it over the weekend...).
What is the problem? How would I empty the DataSet and then re-fill
it so that it won't just die?

- Joerg Colberg
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

It doesn't look like a problem with the DataSet. You can however check this
by calling the Clear() method on the DataSet before re-filling it with data.
But, you should also try to run the SQL statement for the sqlcmd2 command in
Query Analyzer and see whether it ever makes it to the end there.
 
M

Miha Markic [MVP C#]

Hi Joerg,

As Dmitriy stated, there is proably a problem communicating with database.
Are you sure that program is stopped within Fill statement and no exception
is thrown?
Also is this copy&paste code? fill should be Fill.
 
J

Joerg M. Colberg

Hi Dmitriy,
It doesn't look like a problem with the DataSet. You can however check
this by calling the Clear() method on the DataSet before re-filling it
with data. But, you should also try to run the SQL statement for the
sqlcmd2 command in Query Analyzer and see whether it ever makes it to the
end there.

The SQL command works fine. I checked it already. Thing is that
when I modify the command to return less results the whole process
works. That makes me think there is some memory issue or something
similar but it's hard to say anything when there's no error message.

- Joerg
 
J

Joerg M. Colberg

Hi Miha,
As Dmitriy stated, there is proably a problem communicating with database.
Are you sure that program is stopped within Fill statement and no
exception is thrown?

Oh yeah. I checked that a dozen times. I added code to catch ANY
possible exception (got nothing), and I added code that'd output
something on the console between every step in the code.
Also is this copy&paste code? fill should be Fill.

It wasn't copy&paste. That's just a typo. In the code, it's
Fill.

Any idea what's going on? As I wrote to Dmitriy, the whole thing
works well if I reduce the number of rows returned from the DB.
Makes me think there's some memory issue - but how would I know
if there's no error being thrown?

- Joerg
 

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