473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

ADODB.Connection and SQLEXPRESS

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
%>

Jan 7 '08 #1
1 8149
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"
Jan 7 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Channing Jones | last post by:
Hello everyone, I am trying to store data in a binary field of an SQL-Server table using ADODB. So far, I have managed to store a record but not any data in the binary field. I only get...
5
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As...
0
by: Andre Azevedo | last post by:
Hi all ! I've created a .net serviced component with only one method. This method receive an ADODB.Command object and execute it. The ADODB.Command object is created in the client process. (VB...
0
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the...
2
by: MasterChief | last post by:
I have a OLEDB Connection String that is working very well for me. My question is that I read that you can store the Connection String in a seperate include file or somewhere else. I am just...
10
by: cleo | last post by:
I am migrating from VB6/Access to Visual Basic and SQL Express. I have success writing test code on my local machine and am now setting up tests for deployment to a server. I have installed SQL...
3
by: Harry Strybos | last post by:
Hi All I have a really strange problem occurring in my application. When I read in the application settings for connection strings the following happens: Here are my connection string settings...
2
sonu5588
by: sonu5588 | last post by:
I am facing problem in connection. This code is OK , when i Deploy or Create a EXE of this project and install it on other system then the connection error generates, whats the solution to create a...
2
EYE4U
by: EYE4U | last post by:
Hi all, This is how you can connect to an Access Database using ADODB.. First add a reference to Microsoft ActiveX Data Objects 2.0 Library Now to lets Declare some variables : Private Con...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.