Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error handle if sql server connection lost 1

Status
Not open for further replies.

richey1

Technical User
Joined
Oct 5, 2004
Messages
184
Location
GB
Hi

We have an application on one server (server A), which in its global.asa file specifies a connection to another sql server using

Code:
Application("Conn_Z") = "driver={SQL Server};server=Istanbul;database=Envsystem;uid=???;pwd=???"

I use abit of custom code as follows

Code:
	ExecQuery_X "CONN_Z","CCC0026::INSERT INTO tblPubCon_ISB (CallID, CompType,location) values(?,?,?)", Array(adnumeric, 

5,lngEnquiry,adnumeric,5,request("selPub"),adnumeric,5,request("selLocation"))

if the server istanbul , conn_z, is down the code crashes in server A - can i error handle this at all for a disconnected Istanbul server ?

many thanks
jacq

 
thanks for that

I have trie, in my asp, using the code below - still works ok, but if if do put in the datasource name to be purposely wrong, then i get

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. -2147467259 Microsoft OLE DB Provider for SQL Server

which is exactly what i'm trying to avoid !

thanks
jacq

Code:
Dim conn

set conn = server.createobject("ADODB.connection")

on error resume next

conn.ConnectionString = "Provider=sqloledb;Data Source=servername;" & _
        "Database=tblPing;uid=??????;pwd=??????;"

conn.open

If (Err.Number = -2147467259) Then
	Response.Redirect ctsURL("enquirySummary.asp") & "&EnquiryID=" & lngEnquiry & "&target=EnquirySummary.asp?Sid=" & request("sid")
end if


start running insert routines
 
I usually check the count of errors on the connection object. This works well, except for Oracle, which returns an "error" on a successful connection.

So:
Code:
If (conn.errors.count > 0) Then
    Response.Redirect ctsURL("enquirySummary.asp") & "&EnquiryID=" & lngEnquiry & "&target=EnquirySummary.asp?Sid=" & request("sid")
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top