Specify in connection string where MSDE data is stored

  • Thread starter Thread starter Amy
  • Start date Start date
A

Amy

Hi there,

I can using ADO .NET in visual C++ to access an MSDE database. My
connection string looks like this:

"Data Source=(local);Initial Catalog=MyDB;Integrated Security=SSPI"

This goes and gets the database from C:\Program files\Microsoft SQL
Server\MSSQL\Data.

However, my application needs to be able to access databases stored in
other directories. I know you can set the data dir for MSDE at
installation and I'm guessing you can change it through the registry
after that, but is it possible to specify the data location in the
connection string?

Thanks,
Amy
 
Your app should not have, and does not need to, knowledge where data file of
SQL Server/MSDE is located: it is controlled by SQL Server/MSDE when a
database is created in or attached to the SQL Server/MSDE. Your app only
deals with Sql Server/MSDE through ADO.NET, not directly accessing the data
file (*.mdf/*.ldf file). Therefore the connectionString

"Data Source=(local);Initial Catalog=MyDB;Integrated Security=SSPI"

should be working regardless the location of SQL Server's data file
location.
 
I'd like to expand on this explanation.

In current MSDE, which is just a repackaged SQL Server, the server itself
must have the database mounted via an Administrative console.

In the new MSDE 2005, renamed to "SQL Server Express 2005" and slated for
release I believe in 2005, I believe will allow for a more Access like connectionstring
that specifies the database files.

However, as it stands now, the database files must be mounted in SQL Enterprise
Manager (or via scripting) before the database can be used.
 
Thank you for your reply Norman,

Can I just clarify what what you are saying means for our particular
situation? What we want to be able to do is have different databases
used in our application stored in different locations, one on a server
and one at a user-specified location which can be changed (by the
user, through our application). This is a requirement of our client
so we're stuck with it unfortunately. Are you saying that this is
impossible or that it can be done but outside of ADO .NET?

Amy
 
Yes. Just change the connection string. Data Source is the name of the SQL
Server, and Initial Catalog is the name of the database.

Jeff
 
Back
Top