我尝试构建数据库故障转移(ASP 经典),但设置有问题:ConnectionTimeout。我将其设置为 1 秒,但服务器仍然尝试连接到第一个连接超过 20 秒。我喜欢连接将在 1 秒后丢失,因此我可以将用户转移到第二个连接。
谢谢,
<%
DSN = "Provider=SQLOLEDB; Data Source=62.62.62.62; Initial Catalog=150109;User Id=noa; Password=tfdh545h54h;"
DSN1 = "Provider=SQLOLEDB; Data Source=127.0.0.1; Initial Catalog=150109;User Id=noa; Password=tfdh545h54h;"
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionTimeout = 1
conn.CommandTimeout = 1
Set rs = Server.CreateObject("ADODB.RecordSet")
On Error Resume Next
conn.Open DSN
If Err.Number <> 0 Then
conn.Open DSN1
End If
On Error Goto 0
'--
sql ="SELECT TOP 10 *"
sql = sql & " FROM allDB"
rs.Open sql, conn
if (not rs.eof) and (not rs.bof) then
groupARRAY = rs.GetRows
end if
rs.Close
'--
conn.Close
Set rs = Nothing
Set conn = Nothing
%>