Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Passing wild cards to stored procedures


Message #1 by "Jon Shoreman" <Jon.Shoreman@b...> on Thu, 11 Oct 2001 19:55:43
I have a stored query on my access database, the where clause reads

Surname = [param_Surname]



I want to pass the parameter "A*", "B*" "C*", etc. so that a list of names 

starting with that letter are displayed.



The code I am using to create the record Set is:



-----------------------------------------------------------------



qry_PlayerSurname = "S*"



Set PlayerInd_objComm = Server.CreateObject ("ADODB.Command")



PlayerInd_objComm.ActiveConnection = strConnect



PlayerInd_objComm.CommandText = "st_PlayerProfile_Surname"

PlayerInd_objComm.CommandType = adCmdStoredProc

	

PlayerInd_objComm.Parameters.Append PlayerInd_objComm.CreateParameter 

("param_Surname", adChar, adParamInput ,20)

					

PlayerInd_objComm.Parameters ("param_Surname") = qry_PlayerSurname

		

Set PlayerInd_objRS = PlayerInd_objComm.Execute



-----------------------------------------------------------------



No data is returned.



If I set qry_PlayerSurname to equal a surname I know exists, e.g. "Smith" 

then some data is returned.



I can only guess that it is the * that is causing the problem.



Any ideas?
Message #2 by "Jon Shoreman" <Jon.Shoreman@b...> on Thu, 11 Oct 2001 20:07:43
OK, solved the problem by using a % instead of a *



BUT.....if I just run the query in Access it works if I use a *....Why?
Message #3 by "Jose Bueno" <jbueno@i...> on Thu, 11 Oct 2001 22:47:05
What version MDAC are you using?  When I used 2.x (below .5) I compensated 

by using a %.  A year later, I'm starting doing this stuff again, and it 

seems that bug( feature, whatever) has been addressed in 2.7.  Now when I 

try to pass a % into Access I have problems, but the * works just fine... 

go fig.



The technical explanation, at least what I picked up in my time at MS was 

that since the method we're using (ODBC)is bypassing MS JET altogether

(hence why an *.ldb file never appears). That being the case, you had to 

use ANSI SQL, which used % as a wildcard.  I don't know why its apparently 

been changed now to accept * and not %.

  Return to Index