connection strings

  • I have designed a C# application that connect to a local sql server 2008 database.

    The project works fine on my development machine. But I have to deploy it to clients (They will be using stand alone express editions of SQL2008)

    SO,how do I get my development connection strings to work with both my Dev server and the clients sqlexpress server?

    I assume the connection string should include something like "datasource=.\sqlexpress"

    but that means my Deveopment machine (which does not have an instance called sqlexpress) won't debug.

    I've tried "Datasource=(local)" and "Datasource=." with mixed results.

    There must be a logical way of handling this. Do I need to create an alias on my dev machine and call it "sqlexpress" or a create new instance on my Dev machine called "sqlexpress" ?

    Is there a best practice method for handling the differences between required connection strings that will work on a variety of Client stand alone SQL servers in the wild.

  • The connection string I utilized to attach to a SQL Express 2005 database is

    Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TIPSnTRICKS;Data Source=substituteyourclientsmachinename\SQLEXPRESS.

    You might want to consider including in your application a small initialization program which basically displays the microsoft input form titled Data Link Properties which is contained in the Msado15.dll

    ' In project references you MUST select

    ' Microsoft OLE DB Service Component 1.0 Type Library

    ' This in turn loads oledb32.dll into your project

    ' then

    ' Dim objMSDAC As MSDASC.DataLinks

    '

    ' In project reference you MUST select

    ' Microsof ActiveX Data Objects 2.8 Library

    ' This in turn loads Msado15.dll into your project

    '

    ' Sample VB code:

    Set objMSDAC = New MSDASC.DataLinks

    Cnn_String = objMSDAC.PromptNew

    Then write the connection string to an INI file and read same into your main application.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • That appraoch interests me. An initialization method that runs when the user starts the app. It checks the available connections and then updates a file which the connection string reads from. OK so how do I get the connection string to change dynamically... to read this ini file .. OK I'll give this a go. I'll report back ..

  • willferguson

    OK so how do I get the connection string to change dynamically

    The Data Link Properties form is inter-active. The user selects

    1. a server from a drop down list

    2. A login in method

    a). Windows user

    b). Login name and password

    3. Selects from a drop down list of all the databases connected to the selected server.

    4. Clicks on a test button and is informed if selections are valid

    5. Last but not least exits the form.

    All of the above performed by the few lines of code posted previously

    Hope this helps solve you problem, if not repost.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply