Reputation: 602
How do I debug a page in ASP.NET? I have an IIS server that I am trying to add a new page to and when I am running the ASP on the server I get a really short and nondescript error message
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near '='.
/forms/test.asp, line 52
Line 52 is:
Set RS = Conn.Execute(SQL)
Where 'SQL' is a SQL query statement set a few lines earlier. I have checked that statement over and over I am confident that the syntax of the query is solid as a nearly identical query runs without a hitch earlier in the page and other pages run the same thing. I have been working for a while now to try to find the bug with no success.
I am new to ASP and working in an IIS environment. I usually work with Java in which I have a stack trace to gather information and can use console output to track data to help with the debugging process. This is all absent in ASP.
So, what methods can I use to track this bug and solve it? I know I list a specific example here but I really need a general technique I can use to debug ASP. Can I print to a console somewhere to track variable values? Can I send that information out in a popup so I can see what the data looks like before the error? Is there some way to get a more detailed description about what happens on execution so I can track where I am going wrong?
Thank you for your help!
The SQL Statement is:
SQL = "SELECT firstname,lastname FROM clientinfo WHERE [ClientID] = " & Request("ID")
Even if we can solve this problem though, is there some technique to debug ASP easier?
Upvotes: 0
Views: 587
Reputation: 822
Place following:
response.write Request("ID") & "<br>"
response.write SQL
before you call execute SQL Second make sure that your Request("ID") returns number other way your SQL should look like this:
SQL = "SELECT firstname,lastname FROM clientinfo WHERE ClientID = '" & Request("ID") & "'"
loose the brackets because ClientID is not the SQL reserved name.
About debugging classic ASP(VBScript) pages: only way to debug those suckers is to use response.write or move to NET framework which is out of question for you. There are lot of tools which claims that they will allow you to debug Classic ASP pages: do not waste your money and time.
*ADDED: **For debugging period you should also remove "on error resume next" from your pages and do Option Explicit. First will allow you to see where error occurs and second, while making your life a bit harder, will prevent some of the errors because it will not allow you to use any undeclared variables.
Upvotes: 1
Reputation: 42192
ASP or ASP.NET, in both cases you can use a simple logging to a file to debug. Add this to your asp page of common used procedures, i call it routines.asp
and in your page you want to debug you add
<!--#include file="routines.asp"-->
then call the sub when you need it
call debug page, line, varname, varcontents
where page=the name of the asp file and possibly of the procedure or function being executed, line=the linenummer where you call debug, varname and varcontents the name and the variable itself, the first two parameters make it easy to find the source of the logging
eg
call debug "myApp.asp/getOLEdata", "122", "SQL", SQL
Upvotes: 0
Reputation: 101
Judging by the filename "test.asp" it looks to me like you are using ASP and not ASP.NET. I don't know if this is your intention? ASP.NET can be debugged by attaching a debugger (for example Visual Studio) to IIS's worker process (usually w3wp.exe).
Upvotes: 0