ADODB.Connection and SQLEXPRESS

A

Aykut Canturk

Can I use SqlExpress2005 AttachDatabase feature with classic ADO connections
in my .asp pages ? But I need ConnectionString. Although I searched the web
for couple of weeks I still coulnd't find any solution.

anybody succeeded to use classic ado with attach feature without attaching
database filed from enterprise manager ? I want tou use SQL2005 and I don't
want directly attch files to sql.

Best regards...

<%
set cn = Server.CreateObject("ADODB.Connection")

' THIS ConnectionString IS WRONG of course. I need correct and working one

ConnectionString=
"Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=c:\db\mydbfile.mdf;Trusted_Connection=Yes;"

cn.open ConnectionString

..... database operations....

cn.execute sqlstr

cn.close
set cn = nothing
%>
 
B

Bob Barrows [MVP]

Aykut said:
Can I use SqlExpress2005 AttachDatabase feature with classic ADO
connections in my .asp pages ?

I've never done it, but it is supposedly possible
But I need ConnectionString. Although I searched
the web for couple of weeks I still coulnd't find any solution.

anybody succeeded to use classic ado with attach feature without
attaching database filed from enterprise manager ? I want tou use SQL2005
and I
don't want directly attch files to sql.

Best regards...

<%
set cn = Server.CreateObject("ADODB.Connection")

' THIS ConnectionString IS WRONG of course. I need correct and
working one
ConnectionString=
"Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=c:\db\mydbfile.mdf;Trusted_Connection=Yes;"

From www.connectionstrings.com:
*************************************************************************
Attach a database file on connect to a local SQL Server Express
instance:

Driver={SQL Native
Client};Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;
Database=dbname;Trusted_Connection=Yes;

Why is the Database parameter needed? If the named database have
already been attached, SQL Server does not reattach it. It uses the attached
database as the default for the connection.

Attach a database file, located in the data directory, on connect to a
local SQL Server Express instance:

Driver={SQL Native
Client};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;
Database=dbname;Trusted_Connection=Yes;

Why is the Database parameter needed? If the named database have
already been attached, SQL Server does not reattach it. It uses the attached
database as the default for the connection.
*************************************************************************

FWIW, I've had issues connecting to SQL 2005 databases from ASP using
trusted connections. I have had to create a SQL login and use it in my
connection strings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top