Where to store connection info ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob

    #1

    Where to store connection info ?

    Where is the best place to store database connection info in a vb.net
    program ? I do not want to "hard-code" a database name into my program.
    Where could I store and retrieve that information ? Also, could you point
    in the the right direction as to how one might do it ?

    Thanks




  • Cor Ligthert

    #2
    Re: Where to store connection info ?

    Rob,

    The nice thing from (the first used) connectionstrin g is that you cannot
    store it in a database.

    Therefore you have the choise from an XML file, and than make simple a
    dataset by hand or the registry (and than it has to be typed the first time
    in)

    I hope this helps,

    Cor


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Where to store connection info ?

      "Rob" <rwchome@comcas t.net> schrieb:[color=blue]
      > Where is the best place to store database connection info in a vb.net
      > program ? I do not want to "hard-code" a database name into my program.
      > Where could I store and retrieve that information ? Also, could you
      > point in the the right direction as to how one might do it ?[/color]

      ..NET Framework Developer's Guide -- Configuration Files
      <URL:http://msdn.microsoft. com/library/en-us/cpguide/html/cpconconfigurat ionfiles.asp>

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • Rob

        #4
        Re: Where to store connection info ?

        If you store it in an xml file, is there an easy way to get it out ?
        Thanks


        "Cor Ligthert" <notmyfirstname @planet.nl> wrote in message
        news:uu2pVp7fFH A.3256@TK2MSFTN GP12.phx.gbl...[color=blue]
        > Rob,
        >
        > The nice thing from (the first used) connectionstrin g is that you cannot
        > store it in a database.
        >
        > Therefore you have the choise from an XML file, and than make simple a
        > dataset by hand or the registry (and than it has to be typed the first
        > time in)
        >
        > I hope this helps,
        >
        > Cor
        >[/color]


        Comment

        • Cor Ligthert

          #5
          Re: Where to store connection info ?

          Rob,

          Creating a dataset, directly typed in this message so watch typos or
          whatever,
          \\\
          dim ds as new dataset
          dim dt as new datatable
          ds.tables.add(d t)
          dt.columns.add( )
          dt.loaddatarow( new object() {"myconnections tring"},true)
          ds.writexml("my filepath")
          ///
          Reading it back
          \\\
          ds.readxml("myf ilepath")
          myconnectionstr ing = ds.tables(0).ro ws(0)(0).tostri ng
          ///

          That is all.

          I hope this helps,

          Cor


          Comment

          • DraguVaso

            #6
            Re: Where to store connection info ?

            Use an app.config file.
            To read it: strConn =
            System.Configur ation.Configura tionSettings.Ap pSettings.Get(" ConnectionStrin g
            ")

            More info:
            http://msdn.microsoft.com/library/de...ingstorage.asp




            "Rob" <rwchome@comcas t.net> wrote in message
            news:--2dnXthT9tYLVrfR Vn-vQ@comcast.com. ..[color=blue]
            > Where is the best place to store database connection info in a vb.net
            > program ? I do not want to "hard-code" a database name into my program.
            > Where could I store and retrieve that information ? Also, could you[/color]
            point[color=blue]
            > in the the right direction as to how one might do it ?
            >
            > Thanks
            >
            >
            >
            >[/color]


            Comment

            Working...