SQL Connection Problem

Results 1 to 3 of 3

Thread: SQL Connection Problem

  1. #1
    Join Date
    Dec 1969

    Default SQL Connection Problem

    I have been trying to get this to work for some time now. I am using the newer way to connect to SQL to save time.. please look and tell me why it;s telling me it can&#039;t find the sql server I am specifying, I am using the name of the sql server and I also tried the IP address for it.. neither worked:<BR><BR>Dim myConn &#039; Connection Name<BR>Dim RS &#039; Recordset Variable<BR>Dim SQL &#039; Variable for SQL statement<BR><BR><BR>Set myConn = Server.CreateObject("ADODB.Connection")<BR>Set RS = Server.CreateObject("ADODB.Recordset")<BR>myConn.C onnectionString = "Provider=SQLOLEDB;Data Source=this is where i tried the sqlserver name and also IP;User ID=username;Password=mypw;Initial Catalog=dbname"<BR><BR>myConn.Open "UID=username;PWD=pw;"<BR><BR>Also, I have a feeling I might need more after this myConn.Open, or will that work ?

  2. #2
    Join Date
    Dec 1969

    Default Don't add anything after the .open method.

    ...should just be myconn.open

  3. #3
    Join Date
    Dec 1969

    Default SQL *SERVER* Connection...

    SQL is a language. SQL Server is a database.<BR><BR>Okay, off my pedantic soap box.<BR><BR>I don&#039;t know what is wrong, but I can tell you that if you specify the UID and PWD in the connection string, *as you are doing*, then it should be unnecessary--and maybe even wrong--to specify them in the Open.<BR><BR>OH! IN Fact, MAYBE that&#039;s the problem!<BR><BR>You set the ConnectionString but then you WIPE IT ALL OUT when you pass in ANOTHER connection string in the Open!! The first argument to ADODB.Connection.Open *IS* the connection string. 100% the same effect as setting the ADODB.Connection.ConnectionString property!<BR><BR>If you really want to pass the UID and PWD separately, and you really see some reason to user the ConnectionString property instead of just doing OPEN, then do OPEN thus:<BR><BR>myConn.Open , "username", "pw"<BR><BR>*OMIT* the connection string in the open!<BR><BR>Tell me if I&#039;m all wet. I never use .ConnectionString because it always seemed to me to be just a redundant way of doing things, since .Open would accept it just as handily and you *must* do the .Open anyway.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts