Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query works in Query Analyzer - not from ASP

Author  Topic 

PeterBailey
Starting Member

3 Posts

Posted - 2007-02-24 : 11:44:19
I am doing some "Classic ASP" development. I have a problem I have never seen before. I am building up a SQL string to do an update. Once it is built, if I paste it into Query Analyzer, it works perfectly. Here is the string from the response.write:

update myTable set q1=1, q2=2, q3=2, q4=2, q5=1, q6=2, q7=2, q8=1, q9=1, q10=2, q11=3, q12='Help me' where RecordNo=23

When I execute this from the asp page, I get the following error:
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 2: Incorrect syntax near '<'.
/go2.asp, line 28

I have tried this with the OLEDB driver above, and the ODBC driver, same error with both. BTW, Line 28 in my asp is the line that does the execute of the sql string.

I am not sure where to turn at this point - help anyone?

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-02-25 : 07:17:33
if possible then on the profiler and check what query extactly is getting passed to the server, and try to debug it..

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-02-25 : 15:17:08
Are you sending then "Query" to SQL as a Command String, or as a Parameterized query?

If a Command String then output the actual "string" from ASP (e.g. append to a text/log file) so that you can check that the SQL String is EXACTLY as you expect it to be.

As chiragkhabaria says, you can also do this using Profiler, rather than adding Debug code.

You are going to find a rogue "<" in there somewhere!!!!!!!!!!!!!

Kristen
Go to Top of Page

PeterBailey
Starting Member

3 Posts

Posted - 2007-02-25 : 15:31:03
Thanks for the help guys. This is actually some bizarre ASP problem. On my initial page I tested the recordNo - it is numeric and I am sure would work fine in a query. I post this value as hidden to the next page and pick it up there to work with. If I just response.write it, it looks ok (for example 45), but if I ask it if it is numeric, it is not, and it supposedly has a length of 39 - very bizarre - so I can't use CInt on it or anything similar to make it an in and use it to update my table. Something very weird is going on - I have never seen this problem before, I frequently pass vars around this way and use them with no problem. Guess I have to get out the magnifying glass and examine everything. Thanks again for your input. I'll be happy when I can switch to some nice friendly python framework :)

Cheers,

Peter
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-02-26 : 06:08:50
Two "fields" on the form with the same name? If so their values will be an "array" - which may spoil your day!

Kristen
Go to Top of Page

PeterBailey
Starting Member

3 Posts

Posted - 2007-02-27 : 11:31:19
Thanks Kristen. I ended up using a response.write to output the line of html with the hidden variable, and then it worked perfectly - how bizarre - oh well - silly language :)

Cheers
Go to Top of Page
   

- Advertisement -