What you need to do is determine the number of rows belonging to the
datasource itself (in this case a DataTable). For example
ds.Tables(0).Rows.Count
Will give you the number of rows contained in the table.
Likewise if you want the number of columns, you can use the Count property
of the Columns collection:-
ds.Tables(0).Columns.Count
Peter
--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com |
www.opennetcf.org
"Thomas P." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I used VB.NET 2003 to read data from a SqlCe database and show it in a
> DataGrid.
> Now I am looking for a method which returns an integer value with the
> total number of rows and/or colums to me.
>
> Dim cn As SqlCeConnection
> cn = New SqlCeConnection("Data Source = \My
> Documents\Test.sdf;Password=")
> cn.Open()
> Dim cmd As SqlCeCommand = cn.CreateCommand
> cmd.CommandText = "Select numbers From Test"
> Dim da As New SqlCeDataAdapter(cmd)
> Dim ds As New DataSet
> da.Fill(ds)
> DataGrid1.Enabled = False
> DataGrid1.DataSource = ds.Tables(0)
>
> I need to know how many rows the DataGrid1 has because I want to use a
> loop to go through the DataGrid.
> With the following code I plan to read some datas.
>
> ds.Tables(0).Rows(0)(0)
>
> I am a newbee in VB.Net so please try to explain it with simple words
> and some code samples to me. Thans a lot.
>
> Regards,
>
> Thomas Peterson