Results 1 to 3 of 3

Thread: Connection string data source name

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    Connection string data source name

    I have written my first app using a database. One of my connection string is as follows,

    m_cn1.ConnectionString = "Data Source=.\SQLEXPRESS; AttachDbFilename = " & _
    m_cn1mdfPath & ";Integrated Security=True; Connect Timeout=30;" & _
    "User Instance=True"

    I have installed this app on a few computers and all works well, but one.

    My data source name on that PC is "SDCO".

    My question is, is there a way to determine what the datasource name is and assign it to a string?

    something like

    public condatasourcename as string = my data source name on this PC

    m_cn1.ConnectionString = "Data Source=.\" & condatasourcename & ; AttachDbFilename = " & _
    m_cn1mdfPath & ";Integrated Security=True; Connect Timeout=30;" & _
    "User Instance=True"

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Connection string data source name

    Not automatically... you could even have multiple instances on the same computer... I have three.... SQLEXPRESS, SQLServer200R2 and SQLServer2012 .... I *think* you can use SQL DMO to iterate the instances on the machine, put them into a dropdownbox, then have the user select which one to use... I think. You would need to look it up and experiment some.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    Re: Connection string data source name

    Well that blows. I do not want the operators to have any interaction with the setup of this interface. What about something along the lines of;

    public conName1 as string = "SDCO"
    public conName2 as string = SQLEXPRESS"
    etc....


    if m_cn1.ConnectionString = "Data Source=.\" conName1 exists
    m_cn1.ConnectionString = "Data Source=.\" & condatasourcename & ; AttachDbFilename = " & _
    m_cn1mdfPath & ";Integrated Security=True; Connect Timeout=30;" & _
    "User Instance=True"
    else if m_cn1.ConnectionString = "Data Source=.\" conName2 exists


    etc....
    end if



    any examples?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width