Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2008, 08:16 PM
Authorized User
 
Join Date: Mar 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Install Application with Database

Hello all and thanks in advance for any help.

I have built personal applications for a while now, and have used a local database in my applications.

I am currently creating an application that uses a SQL Express 2005 database and the application will be installable and distributable however I have come into an issue with the connection string. I have used them before locally, however I dont understand how it is suppossed to work on an installable application.

I'm using Visual Studio 2005 installation process and requiring SQL Express 2005 installed as a pre-requisite, but how do I get the application to get the correct connection string when the data source could be anything on the users machine?

The closest idea that I can guess is having the application assume the data source by concatenating the machine name and "\SQLEXPRESS", as it seems to be on my machine. So as an example, when the user runs the application, the app finds the machine name is "ACB123" so assumes the Data Source is ACB123\SQLEXPRESS.

Anyway I hope I have explained my situation well enough, and again thanks in advance for any help.

-Esteban

 
Old May 10th, 2008, 08:53 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It shouldn't be necessary to figure out the machine name. If SQL Express is installed to the default instance name, you should be able to get away with any of these:

127.0.0.1\SQLEXPRESS
localhost\SQLEXPRESS
.\SQLEXPRESS

If you are connecting with the native .NET SQL client then this might even work:
(local)\SQLEXPRESS

-Peter
compiledthoughts.com
 
Old May 11th, 2008, 02:32 AM
Authorized User
 
Join Date: Mar 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Awesome thanks. I will test this with some friends on their machines. However you did say that these should work if they had installed SQL Express with the default instance name. So if they did not, what is the common practice? I guess I could create a first-use process that requests the user to enter in the data source if the defaults you've stated above dont work assuming that if they changed the instance name they must know what they're doing enough to understand what to enter for "Default Data Source not found, please enter".

Anyway thanks for the response.

 
Old May 11th, 2008, 11:13 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Yes. I would think so too.

There may also be a way in .NET to discover active SQL servers. I know that you can "browse" your network for instance of SQL in the management studio environments, but I'm not sure if that will pick up named instances.

-Peter
compiledthoughts.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Install certificate with my application wakeup Visual Studio 2005 0 January 16th, 2008 07:01 AM
install database on SQL Server decap_itate VB Databases Basics 0 May 2nd, 2006 10:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.