Sunday, March 25, 2012

Can not connect to SQL Server database with http://Localhost

I followed an example from the Chap 12 of "Beginning Active Server
Pages 3.0 (Wrox 1999)" to connect to my Access and SQL Server databases
with the following Coonection Strings.
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=G:\databases\Movie2000.mdb;" & _
"Persist Security Info=False"
objConn.Open "Provider=SQLOLEDB" & _
"User ID=sa;Initial Catalog=Movie;" & _
"Data Source=G:\Program Files\Microsoft SQL
Server\MSSQL\Data\Movie2000.mdf"
I copied the Movie2000.mdb to my HD, G:\databases. It worked very well
with the http://Localhost, where my Connect.asp file is located. I can
open and display a Recordset object from the ASccess Movies table. But
the connection to SQL Server database failed.
Do I need to modify the ADO connection string properties, i.e.
Provider and/or Dara Source?
TIA,
Jeffrey
Hi
With SQL Server, the client does not know where the DB is on disk, you just
refer to it by name.
objConn.Open "Provider=SQLOLEDB" & _
"User ID=sa;Initial Catalog=Movie;" & _
"Data Source=Movie2000"
This can be accessed after the database is restored or attached into SQL
Server.
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
<cjeffwang@.gmail.com> wrote in message
news:1118821257.151086.23940@.g43g2000cwa.googlegro ups.com...
> I followed an example from the Chap 12 of "Beginning Active Server
> Pages 3.0 (Wrox 1999)" to connect to my Access and SQL Server databases
> with the following Coonection Strings.
> objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=G:\databases\Movie2000.mdb;" & _
> "Persist Security Info=False"
> objConn.Open "Provider=SQLOLEDB" & _
> "User ID=sa;Initial Catalog=Movie;" & _
> "Data Source=G:\Program Files\Microsoft SQL
> Server\MSSQL\Data\Movie2000.mdf"
> I copied the Movie2000.mdb to my HD, G:\databases. It worked very well
> with the http://Localhost, where my Connect.asp file is located. I can
> open and display a Recordset object from the ASccess Movies table. But
> the connection to SQL Server database failed.
> Do I need to modify the ADO connection string properties, i.e.
> Provider and/or Dara Source?
> TIA,
> Jeffrey
>
|||Hi Mike,
I tried using your connection string, but still got an error message:
Error Type:
Microsoft VBScript compilation (0x800A0408)
Invalid character
/Bch12/ConnectSQL.asp, line 30
"User ID=sa;Initial Catalog=Movie;" & _
Any suggestions? Thanks.
Jeffrey
sql

No comments:

Post a Comment