Recordcount in VB.NET 2003

  • Thread starter Thread starter Atley
  • Start date Start date
A

Atley

What is the best way to get a recordcount from a dataset? I can't seem to
find a reliable way to do this...

Any help would be greatly appreciated.

Atley
 
Using the Count property of the Rows collection:-
[C#]
ds.Tables["TableName"].Rows.Count
[VB]
ds.Tables("TableName").Rows.Count


Peter
 
This just give me an empty msgbox, no string no nothing... why?

If sqlClientToList = "" Then sqlClientToList = "Select CName, CDate, CLength
FROM Clients ORDER BY CName"
Dim cnClientGridLoader As New System.Data.SqlServerCe.SqlCeConnection("data
source =\my documents\clientbase\clientbase.sdf")
Dim daClientGridLoader As New
System.Data.SqlServerCe.SqlCeDataAdapter(sqlClientToList,
cnClientGridLoader)
Dim dsClientGridLoader As New System.Data.DataSet
Dim MyCountOfRecords As String
MyCountOfRecords = dsClientGridLoader.Tables(0).Rows.Count & " clients in
the table match your request."
MsgBox(MyCountOfRecords)

There are 5000 records in the client table. Doesn't make sense to me.


Any help would be appreciated, thanks.

Atley


Peter Foot said:
Using the Count property of the Rows collection:-
[C#]
ds.Tables["TableName"].Rows.Count
[VB]
ds.Tables("TableName").Rows.Count


Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

Atley said:
What is the best way to get a recordcount from a dataset? I can't seem to
find a reliable way to do this...

Any help would be greatly appreciated.

Atley
 
Dim daClientGridLoader As New
System.Data.SqlServerCe.SqlCeDataAdapter(sqlClientToList,
cnClientGridLoader)
Dim dsClientGridLoader As New System.Data.DataSet

In the line above, you are creating a brand new but EMPTY dataset

You need to fill the dataset with data:

'Untested Air code:
'This should create a table in the dataset named Clients

daClientGridLoader.Fill(dsClientGridLoader, "Clients")
 
Hi,

I think you're missing these



Atley said:
This just give me an empty msgbox, no string no nothing... why?

If sqlClientToList = "" Then sqlClientToList = "Select CName, CDate, CLength
FROM Clients ORDER BY CName"
Dim cnClientGridLoader As New System.Data.SqlServerCe.SqlCeConnection("data
source =\my documents\clientbase\clientbase.sdf") ---Dim dtTest as new datatable
Dim daClientGridLoader As New
System.Data.SqlServerCe.SqlCeDataAdapter(sqlClientToList,
cnClientGridLoader) ---daClientGridLoader.Fill(dtTest)
Dim dsClientGridLoader As New System.Data.DataSet dsClientGridLoader.Table.Add(dtTest)
msgbox(dtTest.rows.count)
Dim MyCountOfRecords As String
MyCountOfRecords = dsClientGridLoader.Tables(0).Rows.Count & " clients in
the table match your request."
MsgBox(MyCountOfRecords)

There are 5000 records in the client table. Doesn't make sense to me.


Any help would be appreciated, thanks.

Atley


Peter Foot said:
Using the Count property of the Rows collection:-
[C#]
ds.Tables["TableName"].Rows.Count
[VB]
ds.Tables("TableName").Rows.Count


Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

Atley said:
What is the best way to get a recordcount from a dataset? I can't
seem
 
Actually, I had to make sure that I had the connection opened... i had a
line to fill the dataset, i didn't include it in my sample sorry... Thanks
for all your help.

Atley
 
Back
Top