2016-11-15 55 views
-1

你能告诉我如何从0-5岁得等从SQL Server和输入文本框或标签总数是多少?请点击链接样本 Generate Ages从sql server生成时代。 VB.NET

谢谢!

+1

我们可以看到你的代码?而且,你的目标能更明确吗?我不明白什么你愿意做... – romulus001

+0

现在我没有这个尚未代码,因为我不知道如何下手! 对不起,我的英语。我想从例如1-5岁或6-10岁的年龄中获得年龄,并且总结他们在那个年龄的城镇中有多少男性和女性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` 

你的问题,但是,很可怜,通常人们不会把过多的精力投入到回答它,因为你已经把没有努力在自己身上。

+0

赞赏!对于我这个可怜的问题,我很抱歉,因为我有一个小小的英语词汇。我会给这一枪! –

+0

@YevrahAradnop你已经有一个打开连接的连接字符串了吗?这仅仅是如果你使用'MS-Access'过,或者你正在使用'OleDb'另一个DBMS – David

+0

上面的代码就是我要找的。是的,我已经有一个连接字符串,但我的问题是这样的代码。也许我现在需要一些新鲜空气。非常感谢! –