Torna al Thread
<% Option Explicit %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>SQL Server Connection String Testing</title>
</head>
<body>
<%
Dim objConn, objRec, connString, strSQL
'This connection string is working...
connString = "Provider=SQLOLEDB.1; Data Source=xxx.xxx.xxx.xxx; Initial Catalog=nomedb; User Id=username; Password=password;"
'declare and establish open connection.
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = connString
objConn.Open
'test the connection with a simple recordset.
strSQL = "Select Count(*) AS theCount FROM SOMETESTTABLE"
Set objRec = Server.CreateObject("ADODB.RecordSet")
objRec.Open strSQL, objConn
Response.Write "<hr />" & objRec("theCount") & "<hr />"
'Clean up.
objRec.Close
Set objRec = Nothing
objConn.Close
Set objConn = Nothing
%>
</body>
</html>