February 8, 2005 at 11:42 am
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?
February 8, 2005 at 12:54 pm
Have you tried this ? :
strResult = ADOConnection.Execute (strSQL).Fields(0).value
February 8, 2005 at 1:08 pm
Remi,
If I could give you a star I would. I just replaced about 10 lines of code declaring and using a recordset and an ADO Command with your 1 line of code.
Thank you.
February 8, 2005 at 1:39 pm
I'll take that star . But I'll just leave you with this warning : The code I gave you assumes that a value will be returned. When using this method make sure you return only a scalar recordset (1 line and 1 column). This will avoid the performance problem of return too much data for no reason. Also make ABSOLUTELY SURE that a value other than NULL will be returned otherwise you'll get an error. If you query doesn't meet those requirements then you need to use a recordset.
February 8, 2005 at 2:17 pm
I'll keep that in mind. Thanks.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply