Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Value from table

Status
Not open for further replies.

ohmbru2

Technical User
Jul 24, 2001
51
US
I'm trying to retrieve a value from a table from an ActiveX Script Task. The code errors on the msgbox line. I'm not sure why. Any help is greatly appreciated.

Dim strSQL
Dim strResult
Dim conn
Dim dsn

Set conn = CreateObject("ADODB.Connection")
dsn = = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=DATABASE;Data Source=SERVER"
conn.Open dsn


strSQL = "Select top 1 FIELD1 from TABLE order by FIELD1 "
strResult = conn.Execute(strSQL)
msgbox "The value is " & strResult


 
You need to do something like this, you are populating a recordset with your query, so you can't work with it the same way you woud a string:

Code:
msgbox "the value is " & strResult(strResult.Fields.Item(0).Name).Value

Hope this helps,

Alex




Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top