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!

pass param from vbscript to sql

Status
Not open for further replies.

davidste

Programmer
Mar 7, 2004
15
GB
I am trying to run the following t-sql stored proc from my VBScript page

Create Procedure getUserInfo
(
@login nvarchar(8)
)
AS
USE proj_dashboard
SELECT f_forename, f_surname, f_profile_id
FROM t_users
WHERE f_login = @login

basically I wasnt to pull in the login of the user pass it to the proc and pull out the info for that user. I use the following sql statement
strSQL = "EXECUTE getUserInfo(logon)"

where logon is a var containing the users login.

which is passed in to the following function
Private Function RecSet(byVal connstring, byVal SQL)
Const adOpenForwardOnly = 0, adOpenKeyset = 1
Const adOpenDynamic = 2, adOpenStatic = 3
Const adLockReadOnly = 1, adLockPessimistic = 2
Const adLockOptimistic = 3, adLockBatchOptimistic = 4
Const adUseServer = 2, adUseClient = 3
Dim rs, Tmp

Set rs = Server.CreateObject("ADODB.Recordset")
With rs
.CursorType = adOpenStatic
.CursorLocation = adUseServer
.LockType = adLockReadOnly
.ActiveConnection = connstring
.Source = SQL
.Open

If .BOF then
Tmp = Null
Else
Tmp = .GetRows()
End If
.Close
End With


RecSet = Tmp


Set rs = Nothing

End Function

The error I get is Incorrect syntax near 'logon'.

Thank You for any help in advance.
 
Are you getting this error in VB or in SQL?



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
I am getting this error in the browser from the asp page so VB.

Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 1: Incorrect syntax near 'logon'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top