Aykut Canturk wrote:
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;AttachDbFile name=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:\as d\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=|Data Directory|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.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"