Re: ConnectionString for VisualStudio-style SQL Server Databases by William
William
Sat Aug 26 15:48:52 CDT 2006
Yes, you can. The problem is that when you build a project that contains the
database file, Visual Studio works with SQL Server Express to create a user
instance where the database is temporarily attached. The process is kinda
convoluted but if you have Visual Studio Standard or Professional, you can
take the .MDF file generated by Visual Studio, copy it to a convenient
location (outside of your project directories) and use the Server Explorer
to attach it to a specific instance of SQL Server. After that your
connection string would look something like this:
"Data Source=MyMachine\SQLEXPRESS;initial catalog=MyDatabase;integrated
security=SSPI"
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
news:2B649CE2-3EC2-4E27-888E-76DC693D080C@microsoft.com...
> If I create a database or attach a database file in the version of
> SQLServer
> that comes built-in to Visual Studio, the ConnectionString that
> VisualStudio
> automatically creates for connection to this database is a "file-based"
> connection ("AttachDbFileName=...").
>
> Is there a way to attach a database to this version of SQL Server that can
> be connected to from my development code using the "Server=...; Initial
> Catalog=...;" approach instead? This would make it a lot easier to test if
> everything is working as it should.
>
> Alex
>