Results 1 to 4 of 4

Thread: Displaying SQL results

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    6

    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

  2. #2
    Junior Member Aeric's Avatar
    Join Date
    Nov 2006
    Posts
    28

    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

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    6

    Resolved 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
  •  



Click Here to Expand Forum to Full Width