|
-
Jan 12th, 2007, 02:59 AM
#1
Thread Starter
New Member
Displaying SQL results
I hate to ask this question because I think it will be easy to answer but I have searched forums and used google and cant find an answer.
Is it possible to display an SQL querie to a text box or a label caption? - in particular I want to display the results of Sum or Average (which should be a single word answer
eg if I have a table called wind, and 2 columns (date and wind strength) and I want to find the average wind per month I can use the statement
SELECT Average(wind strength) FROM Wind WHERE date = 'Jan'
but how do I tell it to display the result in a text box?
thanks
-
Jan 12th, 2007, 04:40 AM
#2
Junior Member
Re: Displaying SQL results
There are many methods you can use.
I recommend you rewrite your SQL like this:
SELECT Average(wind_strength) AS Avg_Wind_Strength FROM Wind WHERE date = 'Jan'
I am not sure how you store the date record, but your statement "... WHERE date = 'Jan'" is so strange, is it valid?
If you set rst as recordset, then you can use either of the following:
txtAverage.Text = rst(0).Value
txtAverage.Text = rst("Avg_Wind_Strength").Value
txtAverage.Text = rst!Avg_Wind_Strength
txtAverage.Text = rst.Fields(0).Value
-
Jan 12th, 2007, 08:23 AM
#3
Re: Displaying SQL results
What kind of database is this?
Date is a reserved word and should not be used as a field name. This could be causing issues.
-
Jan 12th, 2007, 05:17 PM
#4
Thread Starter
New Member
Re: Displaying SQL results
Thanks, i made up that database as an example - but I can see how to display the results from the first reply.
Thanks for the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|