I am using the MS SQL at the back end Database in my Test Project. The SQL I am trying to execute is as follows:

SELECT LoginID FROM HumanResources.Employee WHERE Title = '@@EMPLOYEE'

Now, I want to pass the Where clause Title value dynamically using Parameters. similar to below section:

'***************** Code Snippet Start *************************
strQuery = "SELECT LoginID FROM HumanResources.Employee WHERE Title = 'Engineering Manager' "

'Connecting the Data through ADODB connection
Set DBConnection = CreateObject("ADODB.Connection")
'Connecting the Database
DBConnection.Open strConnectionString

'Creating Ado Command
Set adoCommand = CreateObject("ADODB.Command")
adoCommand.CommandText = strQuery ' Assigning the sql query which needs to be exwcuted
adoCommand.ActiveConnection = DBConnection ' Assgning the connection through which the command object will work

Set prmEmployee = adoCommand.CreateParameter("@@EMPLOYEE", adVarChar, adParamInput, 50, "sdfsdf Manager")

adoCommand.Parameters.Append prmEmployee
'***************** Code Snippet End *************************

This returns recordset count 1 which is correct. But, it generates error in the following line:

MsgBox strRecordset.Fields.Item(0).Value

It seems that the parameter which was passed from prmEmployee is not at all being used and matching the Title with @@Employee (itself as value due to single quote in the query)

I found during the SP (Stored Procedure) run, there is no requirement of any parameter seperately but works with the similar way. But, Im not getting any sample or example running the flat query without concatenation in the where clause. QTP unplugged by Tarun Lalwani is having a sample with SP only :-(

Let me know if there is a way out for this. Any reference online URL is also welcome.

Thanks in Advance for all your assistance!!!