Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: I have this problem connecting to SQL, please help


Message #1 by "Juan Ageitos" <jageitos@h...> on Tue, 24 Oct 2000 20:00:16 GMT
This is the code:



<%Option Explicit%>

<HTML>

<HEAD>

<TITLE>Testing our connection</TITLE>

</HEAD>

<BODY>



<%

Dim adOpenForwardOnly, adLockReadOnly, adCmdTable

adOpenForwardOnly = 0

adLockReadOnly = 1

adCmdTable = 2



Dim objConn, objRS

Set objConn = Server.CreateObject("ADODB.Connection")

Set objRS = Server.CreateObject("ADODB.Recordset")



Dim strDatabaseType

'Choose one of the following two lines, and comment out the other

'strDatabaseType = "Access"

strDatabaseType = "MSDE"



'Now we use this selection to open the connection in the appropriate way

If strDatabaseType = "Access" Then

  objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _

               "Data Source=C:\datastores\Movie2000.mdb;" & _

               "Persist Security Info=False"

Else

  objConn.Open "Provider=SQLOLEDB;Persist Security Info=False;Data 

Source=Server01;" & _

               "Database=Movie2000;User ID=sa;Password=" & _

               "Initial File Name=C:\MSSQL7\Data\Movie2000.mdf"

End If



objRS.Open "Movies", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable



While Not objRS.EOF

  Response.Write objRS("Title") & "<BR>"

  objRS.MoveNext

Wend



objRS.Close

objConn.Close

Set objRS = Nothing

Set objConn = Nothing

%>



</BODY>

</HTML>



This is the error:



Error Type:

Microsoft OLE DB Provider for SQL Server (0x80040E4D)

Login failed for user 'sa'.

/begasp/connect.asp, line 29



Message #2 by "Ken Schaefer" <ken@a...> on Wed, 25 Oct 2000 18:14:00 +1000
Did you put in the correct password for the sa user?



Cheers

Ken



----- Original Message -----

From: "Juan Ageitos" <jageitos@h...>

To: "ASP Databases" <asp_databases@p...>

Sent: Wednesday, October 25, 2000 6:00 AM

Subject: [asp_databases] I have this problem connecting to SQL, please help





> This is the code:

>

> <%Option Explicit%>

> <HTML>

> <HEAD>

> <TITLE>Testing our connection</TITLE>

> </HEAD>

> <BODY>

>

> <%

> Dim adOpenForwardOnly, adLockReadOnly, adCmdTable

> adOpenForwardOnly = 0

> adLockReadOnly = 1

> adCmdTable = 2

>

> Dim objConn, objRS

> Set objConn = Server.CreateObject("ADODB.Connection")

> Set objRS = Server.CreateObject("ADODB.Recordset")

>

> Dim strDatabaseType

> 'Choose one of the following two lines, and comment out the other

> 'strDatabaseType = "Access"

> strDatabaseType = "MSDE"

>

> 'Now we use this selection to open the connection in the appropriate way

> If strDatabaseType = "Access" Then

>   objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _

>                "Data Source=C:\datastores\Movie2000.mdb;" & _

>                "Persist Security Info=False"

> Else

>   objConn.Open "Provider=SQLOLEDB;Persist Security Info=False;Data

> Source=Server01;" & _

>                "Database=Movie2000;User ID=sa;Password=" & _

>                "Initial File Name=C:\MSSQL7\Data\Movie2000.mdf"

> End If

>

> objRS.Open "Movies", objConn, adOpenForwardOnly, adLockReadOnly,

adCmdTable

>

> While Not objRS.EOF

>   Response.Write objRS("Title") & "<BR>"

>   objRS.MoveNext

> Wend

>

> objRS.Close

> objConn.Close

> Set objRS = Nothing

> Set objConn = Nothing

> %>

>

>

> </BODY>

> </HTML>

>

> This is the error:

>

> Error Type:

> Microsoft OLE DB Provider for SQL Server (0x80040E4D)

> Login failed for user 'sa'.

> /begasp/connect.asp, line 29

>

>



Message #3 by "Juan Ageitos" <jageitos@h...> on Wed, 25 Oct 2000 18:26:49 GMT
Yes I did.





Message #4 by "Juan Ageitos" <jageitos@h...> on Wed, 25 Oct 2000 19:43:01 GMT
Yes Ken I did.  The password is the same.







Message #5 by "Ken Schaefer" <ken@a...> on Thu, 26 Oct 2000 11:43:37 +1000
Sorry, just confirming - you are using UserID=sa and Password



OK, then the problem is (probably) becuase you don't have a ; between the

Password= and Initial File Name



> "Database=Movie2000;User ID=sa;Password=" & _

> "Initial File Name=C:\MSSQL7\Data\Movie2000.mdf"



Each name=value pair needs to be separated by a ;

Try



"Database=Movie2000;User ID=sa;Password=;" & _

"Initial File Name=C:\MSSQL7\Data\Movie2000.mdf"



Cheers

Ken



----- Original Message -----

From: "Juan Ageitos" <jageitos@h...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, October 26, 2000 5:43 AM

Subject: [asp_databases] Re: I have this problem connecting to SQL, please

help





> Yes Ken I did.  The password is the same.

>






  Return to Index