Yevrah Aradnop Yevrah Aradnop - 1 year ago 70 Question

Generate age from sql server. VB.NET

Can you tell me how to get ages from 0-5 and so on from sql server and input the total in a textbox or label? please click the link for sample
Generate Ages

thank you!

Answer Source

Do you mean something like

Dim sql As String = "SELECT age_column FROM your_table WHERE age_column BETWEEN '0' AND '5'"
'The above line selects the all records where age is between 0-5 (Change the variables)

Dim da As New OleDbDataAdapter(sql, connectionstring)
Dim ds As New DataSet
Dim dt as new DataTable

dt = ds.Tables(0).Copy()

' Above code stores the results in an iterable table

Dim i As Integer = 0

For Each dr as DataRow in dt.Rows
i = i + 1

TextBox1.Text = i

 'i will be the total number of records where age is between 0-5, and display it in a `TextBox`

Your question is, however, very poor, and normally people would not put too much effort into answering it, since you've put no effort in yourself.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download