View Single Post
  #2 (permalink)  
Old November 16th, 2004, 12:37 AM
mat41 mat41 is offline
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

This error can indicate the connection string you have chosen to use is incorrect, or some parameter is incorrect. The connection to your database failed.

This is an example of a working connection string printed to the page:

Provider=SQLOLEDB.1; Password=pass; Persist Security Info=True; UID=user; Initial Catalog=DBName; Data Source=PCName;

To avoid putting this on every page, try the following:

1..Create a file called scripts/global.asp containing:
  const uName = "someString"
  const pass = "somePassWord"
  const DBName = "DatabaseName"
  const ServerName = "MachineName"
  Dim = Conn

2..Create a file called scripts/functions.asp containing
Function GetConnectionString()
   GetConnectionString ="Provider=SQLOLEDB.1; " & _
                "Password=" & pass & "; " & _
                "Persist Security Info=True; " & _
                    "UID=" & uName & "; " & _
                    "Initial Catalog=" & DBName & "; " & _
                    "Data Source=" & Servername & ";"
End Function

3..Any page you want a connection put this at the TOP of each page:
<% Option Explicit %>


<% set Conn=server.createobject("ADODB.Connection")
    Conn.Open(GetConnectionString)
    'to see your connection string on the page:
    response.write GetConnectionString() %>


Wind is your friend
Matt
Reply With Quote