Damn it! I solved my own problem before I got through typing it out. I thought I'd better post it anyway in case somebody else had the same problem.
I solved it by using % instead of * in the LIKE clause.The original question is below...
------------------------------------------
Hi I've got a problem passing parameters to an Access2000 paramatized query from ASP.
I got the following code from another post and it seems to work as long as the WHERE statement uses = [ ] rather than LIKE *[ ]*. It simply returns no results. But when I run the same query from Access, it returns what it should.
The asp code:
-------------------------------
Dim rs
Dim cmd
Set cmd = Server.CreateObject("ADODB.Command"
Set rs = Server.CreateObject("ADODB.Recordset"
With cmd
.ActiveConnection = Application("dbConnectionString"
.CommandText = "qtest2"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("empName", adVarChar, adParamInput, 50)
.Parameters("empName".value = "joe bloggs"
End With
rs.Open cmd, , adOpenStatic, adLockOptimistic
----------------------------
The Access query that works:
SELECT EmployeeNumber, EmployeeName
FROM tCV
WHERE EmployeeName=[empName];
The Access query that I want to use but doesn't return anything:
SELECT EmployeeNumber, EmployeeName
FROM tCV
WHERE EmployeeName Like "*" & [empName] & "*";
I solved it by using % instead of * in the LIKE clause.The original question is below...
------------------------------------------
Hi I've got a problem passing parameters to an Access2000 paramatized query from ASP.
I got the following code from another post and it seems to work as long as the WHERE statement uses = [ ] rather than LIKE *[ ]*. It simply returns no results. But when I run the same query from Access, it returns what it should.
The asp code:
-------------------------------
Dim rs
Dim cmd
Set cmd = Server.CreateObject("ADODB.Command"
Set rs = Server.CreateObject("ADODB.Recordset"
With cmd
.ActiveConnection = Application("dbConnectionString"
.CommandText = "qtest2"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("empName", adVarChar, adParamInput, 50)
.Parameters("empName".value = "joe bloggs"
End With
rs.Open cmd, , adOpenStatic, adLockOptimistic
----------------------------
The Access query that works:
SELECT EmployeeNumber, EmployeeName
FROM tCV
WHERE EmployeeName=[empName];
The Access query that I want to use but doesn't return anything:
SELECT EmployeeNumber, EmployeeName
FROM tCV
WHERE EmployeeName Like "*" & [empName] & "*";