Saturday, February 25, 2012

Can anyone please tell me what is wrong with this query

Can anyone please tell me what is wrong with this query:

rsOtherSubCatagories.Source = "SELECT * FROM SubCatagories WHERE SubCatagoryID = " + Replace(rsSubCatagories__MMColParam, "'", "''") AND CatagoryID = " + Replace(rsOtherSubCatagories__MMColParam, "'", "''")

In DreamWeaver the bit in bold is greyed out, why?

rsOtherSubCatagories.Source = "SELECT * FROM SubCatagories WHERE SubCatagoryID = " + Replace(rsSubCatagories__MMColParam, "'", "''") AND CatagoryID = " + Replace(rsOtherSubCatagories__MMColParam, "'", "''")

Thanks Joe

Hey Joe,

you're missing some( + " ), try this:

rsOtherSubCatagories.Source = "SELECT * FROM SubCatagories WHERE SubCatagoryID = " + Replace(rsSubCatagories__MMColParam, "'", "''") + " AND CatagoryID = " + Replace(rsOtherSubCatagories__MMColParam, "'", "''")

|||

Hikpeguero,

thanks very much for answering, that has stopped the error message but it isnt actually working though...

Im trying to test and see if the current record set is a subcategory in the database, the record im testing is, but it isnt being picked up as one.

This is the basic structure of the table "SubCatagories" im running the query on:

|SubCatagoryID|CatagoryID|"CatagoryName"|
|241|0|"Cat Types"|
|242|0|"Dog Types"|
|243|0|"Fish Types"|
|244|0|"Insect Types"|
|427|243|"Anglers"|
|428|243|"Anthias"|
|429|243|"Basslets"|

The values im trying to check above equate to the query string passed in the URL: page.asp?SubcatagoryID=428

If the current Query string is "428" (Anglers) then it is a subcategory of "243" (Fish Types) as the code loops through the records I need it to check if the query string "428" is associated with the SubCategoryID record being loped through at the time. It should check the Request.QueryString("SubCatagoryID") against the CategoryID of the other records for a match, When it gets to "243" (Fish Types) for example it should find that the current QueryString("SubcatagoryID") of 428 maches, because the CatagoryID in that record matches the (Fish Types) SubCatagoryID.

rsSubCatagories__MMColParam = 428 and rsOtherSubCatagories__MMColParam = 243 Thus the query:

rsOtherSubCatagories.Source = "SELECT * FROM SubCatagories WHERE SubCatagoryID = " + Replace(rsSubCatagories__MMColParam, "'", "''") + " AND CatagoryID = " + Replace(rsOtherSubCatagories__MMColParam, "'", "''")

What is the best way to test for this, should I open a new database connection and run a query for each record? And if so how would I construct the query to check this?

Thanks for your help, Joe

No comments:

Post a Comment