January 17, 2002 at 3:19 am
I am wanting to deploy a demo copy of my VB app via internet using MS Access as the database. Later will ship MSDE or sell SQL 2000.
I wish to use essentially the same code base for both db's but having trouble with an Access query.
Code is:
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Set rs = CreateObject("ADODB.Recordset")
Set cmd = CreateObject("ADODB.Command")
'Run the procedure
cmd.ActiveConnection = objconn
' if SQL has to be %, Access *
cmd.CommandText = "SELECT * From Customers Where customer_id like '" & _
txtCustLookup.Text & "*'"
cmd.CommandType = adCmdText
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenForwardOnly, adLockReadOnly
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
Debug.Print rs.RecordCount
The code runs however never returns anything, must be so basic?
January 17, 2002 at 5:23 am
If you're use MSDE from the beginning you'll save some headaches. I'd recommend you create a constant called Wildcard and set it equal to the asterisk, someday when you upgrade you can just change it to the percent sign for SQL. Not sure why you're using the like with double wildcard, shouldn't your ID be a straight lookup? In SQL a trailing wildcard is ok, still will use indexes. A leading wildcard generally means a tablescan (final results depend on the construct of the entire query).
Andy
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply