tags:

views:

193

answers:

6

Hi

I have moved an sql database from one server to a new one (detached/attached)

Now i experience some strange behavior as it does not work but NO error is displayed.

This is the code

<%
const database_dsn="PROVIDER=SQLNCLI10; SERVER=FR-2626\SQLLOP;DATABASE=Lop;Uid=admin-sql;Pwd=xxxx;" 

response.write "Step 0//"

set conn=server.CreateObject("ADODB.Connection")
set RS=server.CreateObject("ADODB.Recordset")

conn.Open database_dsn

response.write "Step 1//"
req = "Select count(*) From tblArticleList"

response.write "Step 2//"
set RS = conn.Execute(req)

response.write  "Step 3//"

%>

The program stops at Step 2; then nothing, no error is displayed...

I just don t know what to do..How can i get some error?

Thanks Jonathan

A: 

Oh i partially found the answer for the error display.

In the Debug pane of the IIS directory configuration, Enable ASP debugging should NOT be checked...althought i thougth it should...

A: 

I think Server has a GetLastError method, which you can check to find out what error occurred while running any statement.

e.g. On error resume next .... statement that could cause an error.... errorObject = Server.GetLastError()

For ASPError object, refer http://www.w3schools.com/asp/asp_ref_error.asp

shahkalpesh
+1  A: 

have you got your browser set to "show friendly http errors" this in conjuction with what you have already identified is the common causes I've had for not seeing an error message.

Shahkaplesh is also right that you can use Server.GetLastError() to get the last error that occurred but you shouldn't need to do this in this example.

MJJames
"Show friendly HTTP errors" won't show nothing, it just won't show you anything worth while.
AnonJr
Having said that, he should be seeing something...
AnonJr
+1  A: 

When executing a query you don't use the "Set" command. I don't know why its not showing you anything, but your code should look more like this:

<%
const database_dsn="PROVIDER=SQLNCLI10; SERVER=FR-2626\SQLLOP;DATABASE=Lop;Uid=admin-sql;Pwd=xxxx;" 

response.write("Step 0//")

set conn=server.CreateObject("ADODB.Connection")
set RS=server.CreateObject("ADODB.Recordset")

conn.Open database_dsn

response.write("Step 1//")
req = "Select count(*) From tblArticleList"

response.write("Step 2//")
RS = conn.Execute(req)

response.write("Step 3//")
%>

Yes, the parentheses on the "Response.Write" are optional. But I'm OCD like that and it makes troubleshooting a little easier.

AnonJr
A: 

Actually don't mean to be disagreeable, but yes you do need a Set there, as you are setting an object type and presumably wanting to use the return value at some point (if this wasn't just a test script which it looks like to me).

Also btw parentheses are not really correct there in Response.Write() as it does not return a value. They only happen to work on single parameter subs because you can put parentheses anywhere you like around expressions.

eg:

 a = (b)
 Response.Write ((("test"))&(1))
mike nelson
+1  A: 

You need to place error checking code to find out what the actual error might be. I would suggest that you change you code like so:

<%
const database_dsn="PROVIDER=SQLNCLI10; SERVER=FR-2626\SQLLOP;DATABASE=Lop;Uid=admin- sql;Pwd=xxxx;"

'Its very important to add this line!!! '
On Error Resume Next
'Its very important to add this line!!! '

response.write "Step 0//"

set conn=server.CreateObject("ADODB.Connection")
set RS=server.CreateObject("ADODB.Recordset")

conn.Open database_dsn

if err.number<>0 then
    response.write err.description
end if

response.write "Step 1//"
req = "Select count(*) From tblArticleList"

response.write "Step 2//"
set RS = conn.Execute(req)

if err.number<>0 then
    response.write err.description
end if

response.write  "Step 3//"

%>