PC Review


Reply
Thread Tools Rate Thread

Determining SQL Server 2008 Instance Name?

 
 
Jason
Guest
Posts: n/a
 
      27th Sep 2010
I'm building a "Setup and Deployment" project to distribute our
application. We have a database called dbMain that runs on SQL Server
2008. I'm connecting to the database from our WPF Application via the
app.config file, and here are the particulars:

---------------------------------------------------------------------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="ConnectionString"
connectionString="Data Source=.\SSE2008;AttachDbFilename=|
DataDirectory|\DB\dbMain.mdf;Integrated Security=True;User
Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

---------------------------------------------------------------------------------------------------------------------------------------------------------------

As you can see, the connection string is:

Data Source=.\SSE2008;AttachDbFilename=|DataDirectory|\DB
\dbMain.mdf;Integrated Security=True;User Instance=True

Since our database is "dbMain.mdf", and the install script installs it
into the DB folder, I have no problems with that. The problem arises
with the Data Source=.\SSE2008

Since I have no control over the Sql Server 2008 install, or what
instance name the guy who set it up gave it, this program will bomb
when run as is (as SSE2008 is the name I gave my SQL Server 2008
instance).

Is there are way to determine the instance of the SQL Server 2008
instance at runtime (when the program gets the configuration string)
and modify it so that the program will not bomb?

What is the best way to handle this situation programmatically ( or is
there ? )?

Thanks,
Jason
 
Reply With Quote
 
 
 
 
Cubaman
Guest
Posts: n/a
 
      28th Sep 2010
On Sep 27, 8:15*pm, Jason <jason.wu...@gmail.com> wrote:
> I'm building a "Setup and Deployment" project to distribute our
> application. *We have a database called dbMain that runs on SQL Server
> 2008. *I'm connecting to the database from our WPF Application via the
> app.config file, and here are the particulars:
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
> * * <configSections>
> * * </configSections>
> * * <connectionStrings>
> * * * * <add name="ConnectionString"
> * * * * * * connectionString="Data Source=.\SSE2008;AttachDbFilename=|
> DataDirectory|\DB\dbMain.mdf;Integrated Security=True;User
> Instance=True"
> * * * * * * providerName="System.Data.SqlClient" />
> * * </connectionStrings>
> </configuration>
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> As you can see, the connection string is:
>
> Data Source=.\SSE2008;AttachDbFilename=|DataDirectory|\DB
> \dbMain.mdf;Integrated Security=True;User Instance=True
>
> Since our database is "dbMain.mdf", and the install script installs it
> into the DB folder, I have no problems with that. *The problem arises
> with the Data Source=.\SSE2008
>
> Since I have no control over the Sql Server 2008 install, or what
> instance name the guy who set it up gave it, this program will bomb
> when run as is (as SSE2008 is the name I gave my SQL Server 2008
> instance).
>
> Is there are way to determine the instance of the SQL Server 2008
> instance at runtime (when the program gets the configuration string)
> and modify it so that the program will not bomb?
>
> What is the best way to handle this situation programmatically ( or is
> there ? )?
>
> Thanks,
> Jason


In Sql Management Studio:

SELECT @@SERVERNAME

But you can't connect to a service wich name/location is unknown.. So,
ask your dba for right credentials.

Best regards

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
BCM 2007 Shared Database on member Server 2008 in SBS 2008 Domain Andrew Parker Microsoft Outlook BCM 1 5th Feb 2010 03:18 PM
Visual studio 2008 remote debugger SP1 on Windows Server 2008 Julien Microsoft ASP .NET 2 18th May 2009 06:38 PM
Visual studio 2008 remote debugger SP1 on Windows Server 2008 Julien Microsoft ASP .NET 0 18th May 2009 01:22 PM
Porting from 32 bit Windows server 2008 to 64 bitWindows Server 2008 Michael Richard Microsoft VC .NET 3 2nd May 2008 11:09 PM
Microsoft Webcasts SQL Server 2008 Visual Studio 2008 Dutt Microsoft Dot NET 0 8th Feb 2008 02:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:58 AM.