Many people who get errors in SQL statements post their ASP code and the error, and say "what's wrong with this SQL statement?" It's hard for anyone to tell when you've got a SQL statement that hasn't been built yet, for example:
<% sql = "SELECT my_column FROM my_table WHERE my_id = " & my_var set rs = conn.execute(sql) %>
|
If all the information we have is the above, you may as well have called your mechanic, told him you have a problem with your car, and then gave him your license plate number. We have no idea if you have a column named my_column, have a table named my_table, have permissions to that table, what datatype my_id is, and what value (if any) is present in my_var.
To debug this properly, when you get an error, you should add the following two lines:
<% sql = "SELECT my_column FROM my_table WHERE my_id = " & my_var response.write sql response.end set rs = conn.execute(sql) %>
|
Now, you can copy the SQL statement from the browser and post it directly in Access or Query Analyzer, and you might get a little bit more infor about why it's not working. Sometimes it will be obvious even before that point, e.g. my_var is empty or the wrong data type; you should put quotes around a string, enclose # around a date, or remove the quotes around a numeric; or you are using a reserved word (like DATE) for a column name (see
Article #2080).
If you still can't solve the issue, we can't even come close to helping you unless you include the SQL statement above, the actual error message, and following as many of the recommendations in
Article #5006 as possible--most importantly the structure of the table, including data types. Following these steps, you are likely to solve your problem much quicker than people who post their ASP code and just ask us to fix it. The latter will almost always result in a "we need more info" type of reply.