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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Value Into ActiveX Task Local Variable

Status
Not open for further replies.

EdwinGene

Programmer
Sep 2, 2003
154
US
I have set up an ADO connection to a SQLServer DB in VBScript in an ActiveX Task. What I want to do is return a uniqueidentifier value from this connection directly to a local variable in the script.

The essential parts of my code are as follows:

Dim strSQL, strResult
strSQL = "Select NewId()"
strResult = ADOConnection.Execute strSQL


I get an "expected end of statement" error on the SQL Execute statement.

Is there a way to return a value from the select statement directly to a local variable in the ActiveX script?
 
I think you are asking a way round the following, but manual puts it out something like this. I think Execute method always returns a resultset.

Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
...
rs = ADOConnection.Execute(strSQL)
Set Flds = rs.Fields
For Each fld In Flds
strResult=fld.Value
Next
rs.Close

Cheers


[blue]Backup system is as good as the latest recovery[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top