Link to home
Start Free TrialLog in
Avatar of scotts27
scotts27

asked on

Retrieving a single data item from a table

I would like to runa  simple select statement:

BooksConnection.Execute "SELECT LineOfText FROM ImportCheck WHERE ProviderID = " & ProviderID & " AND LineNumber = " & Counter

This works. How do I place that one data item (LineOfText) into a variable so I can use it? Does it go into some default recordset? I am not getting an error and I use many SQL statements in my code now for Inserts and deletes

Thanks
                                 
ASKER CERTIFIED SOLUTION
Avatar of wsh2
wsh2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of scotts27
scotts27

ASKER

I tried this as wriiten and VB give me an error on the set rs = line. It says "Expected End of Statement" I simplified it to the most basic select statement and I still get this.

I have worked around it defining the record set and the select statement and using and rs.cursurlocation and an rs.open statement.

I would like to get it working the way wsh2 suggests if possible. It is much simpler and easier to read.  thanks
Simplke fix to the design time error message.. Change this statement

From:

set rs = BooksConnection.Execute "SELECT LineOfText FROM ImportCheck WHERE ProviderID = " & ProviderID & " AND LineNumber = " & Counter

To:

set rs = BooksConnection.Execute ("SELECT LineOfText FROM ImportCheck WHERE ProviderID = " & ProviderID & " AND LineNumber = " & Counter)

ie. just put parenthesis around your query).. <smile>.