Hi there,
Begin here for the long story.
While I use databases, much of the content of my site is stored in text files (named 1.txt, 2.txt, 3.txt etc.). These numbers correspond to the primary key of one of my Acess database tables which serves as a sort of index for these.
Anyway, I'm making a search engine for the site, and while I can identify which text files include the search string, I can't make the correlation between the text file and the appropriate record in my database.
I have been able to take the text file name and shorten it to simply the number, leaving me with a string that contains a number in it.
Begin here for the short story
I need to SELECT a number of fields from a table in records WHERE the primary key is equal to a specific number. The problem is, this number is contained in a string, not an integer. How should I go about changing its data type, considering I'm using ASP and VBScript?
What I've tried
I tried to be tricky and convert each digit of the number (first checking to see how many digits it was) with the asc() command, then subtracting 48 from that result (the number 0-9 in ASCII being 48-57). Still, this yields the data type mismatch error. Should I just switch languages for this page? Anyway, here's some convoluted code:
'Determine the number of digits in the ListID
'Then convert to ASCII, adjust to actual number... JESUS CHRIST!
if len(fileNumString) = 1 then
fileNumNumber = asc(fileNumString) - 48
end if
if len(fileNumString) = 2 then
tempIntOnes = Right(fileNumString, 1)
tempIntOnes = asc(tempIntOnes) - 48
tempIntTens = asc(fileNumString) - 48
fileNumNumber = (tempIntTens * 10) + tempIntOnes
end if
if len(fileNumString) = 3 then
tempIntOnes = Right(fileNumString, 1)
tempIntOnes = asc(tempIntOnes) - 48
tempIntTens = Mid(fileNumString, 1, 1)
tempIntTens = asc(tempIntTens) - 48
tempIntHuns = asc(fileNumString) - 48
fileNumNumber = (tempIntHuns * 100) + (tempIntTens * 10) + tempIntOnes
end if
sSQL = "SELECT ListID, ListAuthor, ListTitle, ListDescription FROM Playlists WHERE ListID = '" & fileNumNumber & "'"
Thanks for any help you can give :-)