pulling from a database

Results 1 to 2 of 2

Thread: pulling from a database

  1. #1
    Join Date
    Dec 1969

    Default pulling from a database

    I am trying to check a field in an access database to see whether it contains a certain number. I figured that by using instr(table variable, numeric variable) I can test to see if the number is contained in the field but the problem arises if the number is contained in a larger number. For example if I am looking for a 6 it tells me the number I am looking for is there even if there is a 16. The field can hold multiple numbers set up like this 2, 5, 9, 12. How do I check to see if the number is in the database but make sure it is not part of a larger number? Here is the code I am using currently:<BR><BR>&#060;%<BR> &#039 Open database<BR> Set DBConn = Server.CreateObject("ADODB.Connection")<BR> DBConn.Open ODBCDNS<BR><BR> &#039 Get all records from the table<BR> SQL = "SELECT * FROM Businesses"<BR><BR> Set QTable = DBConn.Execute(SQL) <BR><BR> QTable.MoveFirst<BR> Do While Not QTable.EOF<BR> iCategory = QTable("category")<BR> iCategory = "&#124" & Replace(iCategory, ", ", "&#124") & "&#124"<BR> <BR>&#039 this checks the string iCategory to see if it has the appropiate category number in it<BR> if left(instr(iCategory, Category), 1) = "&#124" then<BR>%&#062;

  2. #2
    Eddie Campbell Guest

    Default RE: pulling from a database

    As you are replacing the commas with &#124, you could test for the existence of &#124 6&#124 rather than just 6. This should exclude 16 from the test.<BR><BR>HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts