从sql server生成年龄。 VB.NET

时间:2016-11-15 16:47:53

标签: vb.net

你能告诉我如何从0-5开始从sql server获取年龄等等,并在文本框或标签中输入总数吗?请点击链接查看样品 Generate Ages

谢谢你!

1 个答案:

答案 0 :(得分:0)

你的意思是

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

da.Fill(ds)
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
Next

TextBox1.Text = i

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

然而,你的问题非常糟糕,通常人们不会花太多精力去回答它,因为你已经不费力了。