Newbie question

  • Thread starter Thread starter Adriano
  • Start date Start date
A

Adriano

hello,

how to count number of rows of a table before loading it to dataset and pass
this value to Textbox1.text

thanks in advance,
Adriano
 
Textbox1.Text=myTable.Rows.Count.ToString()

--
Bob Powell [MVP]
Visual C#, System.Drawing

The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
 
Hello Bob,

I tried
TextBox1.Text = ok_main.Rows.Count.ToString
and the following message appeared: name 'ok_main' is not declared,
then corrected it in that way:

Dim ok_main As New System.Data.DataTable()
TextBox1.Text = ok_main.Rows.Count.ToString()

No result :(
textbox1 shows 0

any orther ideas???

thaks in advance,
Adriano
 
Hi Adriano,

I am not sure what you do mean, however when you want the count from the
datatable before it is filled you can use this.
\\\
Dim cmd As SqlCommand
Dim sqlstring As String = "select count(*) from tbl"
cmd = New SqlCommand(sqlstring, conn)
cmd.Connection.Open()
Dim count As Integer = CInt(cmd.ExecuteScalar())
conn.Close()
///
I hope this helps a little bit?

Cor
 
hello Cor,

thanks for reply, that was exactly what I was looking for, it works great!
if you don't mind I have one more question,
I have an Sqlconnection1 and Sqlcommand1 in designer,
now i just want to run that command, what would be the code for that?

thx in advance,
Adriano
 
Back
Top