Dataset restrict row syntax

  • Thread starter Thread starter Earl
  • Start date Start date
E

Earl

I haven't seen this dataset fill syntax used very often and couldn't find it
in the MSDN (found it in a response to replacing TOP), so I'm curious if
this is zero-based or 1-based, and what the integer arguments represent. Am
I filling row 1 to row 1?

da.Fill(ds, 1, 1, "dt")
 
Hi Earl,

I am not sure on this, too :-) - I suggest you to try and see what happens.
However, you might avoid using TOP in this way as it does nothing to prevent
selection of all records - it just fetches requested ones.
Even worse, if you don't start with first, all of the records from 1 to
(start+count) will be fetched (just the count records will be insterted in
DataTable).
The bottom line is, that is better to use properly formatted SQL statements
for this kind of job.
 
Ahhh .. but were it possible! I'm using SQLCE and TOP is not allowed, thus
this is the recommended hack.

Miha Markic said:
Hi Earl,

I am not sure on this, too :-) - I suggest you to try and see what
happens.
However, you might avoid using TOP in this way as it does nothing to
prevent selection of all records - it just fetches requested ones.
Even worse, if you don't start with first, all of the records from 1 to
(start+count) will be fetched (just the count records will be insterted in
DataTable).
The bottom line is, that is better to use properly formatted SQL
statements for this kind of job.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Earl said:
I haven't seen this dataset fill syntax used very often and couldn't find
it in the MSDN (found it in a response to replacing TOP), so I'm curious
if this is zero-based or 1-based, and what the integer arguments
represent. Am I filling row 1 to row 1?

da.Fill(ds, 1, 1, "dt")
 
Just a little update. I used the syntax of "da.Fill(ds, 0, 1, "dt")" to
populate a single record. Since I would normally expect no more than a
handful of records per customer, pulling those few extra records out of the
fairly thin table might be acceptable despite the inefficiency.

Miha Markic said:
Hi Earl,

I am not sure on this, too :-) - I suggest you to try and see what
happens.
However, you might avoid using TOP in this way as it does nothing to
prevent selection of all records - it just fetches requested ones.
Even worse, if you don't start with first, all of the records from 1 to
(start+count) will be fetched (just the count records will be insterted in
DataTable).
The bottom line is, that is better to use properly formatted SQL
statements for this kind of job.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Earl said:
I haven't seen this dataset fill syntax used very often and couldn't find
it in the MSDN (found it in a response to replacing TOP), so I'm curious
if this is zero-based or 1-based, and what the integer arguments
represent. Am I filling row 1 to row 1?

da.Fill(ds, 1, 1, "dt")
 
Earl said:
Just a little update. I used the syntax of "da.Fill(ds, 0, 1, "dt")" to
populate a single record. Since I would normally expect no more than a
handful of records per customer, pulling those few extra records out of
the fairly thin table might be acceptable despite the inefficiency.

Yeah, that is an architectural poblem :-)
It mostly depends on your judgement.
 
Even if the folks who designed SQLCE see this, it's too late to fix their
"architectural problems". I would certainly agree that it was not the best
of judgment to eviscerate SQL for SQLCE, but for what it's worth, that's my
opinion about the Compact Framework also.
 
Back
Top