Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ADODB.Connection and SQLEXPRESS

Reply
Thread Tools

ADODB.Connection and SQLEXPRESS

 
 
Aykut Canturk
Guest
Posts: n/a
 
      01-07-2008
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;AttachDbFile name=c:\db\mydbfile.mdf;Trusted_Connection=Yes;"

cn.open ConnectionString

..... database operations....

cn.execute sqlstr

cn.close
set cn = nothing
%>

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      01-07-2008
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"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IIS7 on Vista and SQLExpress problem =?Utf-8?B?bXVzb3NkZXY=?= ASP .Net 5 09-14-2007 03:08 AM
Connection string not working when moving from sqlexpress to sqlserver John ASP .Net 3 10-16-2006 06:35 PM
membership, SQLExpress and/or SQLServer dgk ASP .Net 2 09-15-2006 01:26 PM
First field won't update (sqlexpress) Edwin Knoppert ASP .Net 1 12-28-2005 02:44 PM
Visual Studio 2005 and SqlExpress olduncleamos ASP .Net 1 07-22-2005 02:36 AM



Advertisments