[RESOLVED] SQL: Select Query Results
Hello!
First of all let me say a big thank to all the people contributing in this forum helping us improving our VB knowledge ... Now, let me post my question!
I have an application where number from 0 to 60 are my entries and saved into a tbl with the relevant Date of Entry. I run an SQL query, count and grouping numbers according to their frequency and date of entry and send them to a form. Up to now everything ok. What i need now....
Assume that we have a table with the following type of records:
1 12
2 10
3 22
4 8
5 6
The first column is the Number Entered and the second one is the Frequency. I want to run a Select Query, Order by Ascending Order and present the results on textboxes, E.g from the above example to have 5 boxes and the relevant results. How?
Actually I need to know how to play with the SQL query ...
Thanks
Re: SQL: Select Query Results
There's nothing complex about the query. It's just something like:
SQL Code:
SELECT Column1, Column2
FROM MyTable
ORDER BY Column2
Assuming you don't know how many rows there will be, you'd have to get the record count and then create that many TextBoxes and place them on your form in code. If you know the number of records beforehand then you can add the TextBoxes at design time.
Either way, I'd suggest adding the TextBoxes to an array and then using a For loop to loop through the TextBoxes and records simultaneously, populating the TextBoxes as you go. We can't really tell you how to do that because we don't know what language your app is written in. I guess it's VB but is that VB6 or VB.NET?
Re: SQL: Select Query Results
Quote:
Originally Posted by
jmcilhinney
There's nothing complex about the query. It's just something like:
SQL Code:
SELECT Column1, Column2
FROM MyTable
ORDER BY Column2
Assuming you don't know how many rows there will be, you'd have to get the record count and then create that many TextBoxes and place them on your form in code. If you know the number of records beforehand then you can add the TextBoxes at design time.
Either way, I'd suggest adding the TextBoxes to an array and then using a For loop to loop through the TextBoxes and records simultaneously, populating the TextBoxes as you go. We can't really tell you how to do that because we don't know what language your app is written in. I guess it's VB but is that VB6 or VB.NET?
Well It is VB6. But in any case i do not have problem with the query but... assume that I select by order (e.g ascending one). How can I put in first textbox the number ordered first, then second etc?
Re: SQL: Select Query Results
Lable1 = rs.Fields(0).Value
TextBox1.rs.Fields(1).Value
rs.moveNext
.....
Re: SQL: Select Query Results
Quote:
Originally Posted by
GaryMazzone
Lable1 = rs.Fields(0).Value
TextBox1.rs.Fields(1).Value
rs.moveNext
.....
thanks a lot. I will try and confirm if it is ok. But many thanks in any case :)
Re: SQL: Select Query Results
Thanks a lot... it works :)
Stefanos
Re: SQL: Select Query Results
As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).