Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to develop an sql connection string from a text or xml file: how do i?

how to develop an sql connection string from a text or xml file: how do i?

Scheduled Pinned Locked Moved Visual Basic
databasesysadminquestionxmlhelp
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JustmeNick
    wrote on last edited by
    #1

    Ok thank you guys. But can any one help me with this? My program would have a initial setup screen where the system admin will suply all the necessary informatoin such as the server name, pasword, username and stuff like that... all this information would be written to a text file somewhere on the hard drive. The program should then take the server name, user name and password from the text file to create the connection string to connect to the database (sql 2000) How do i go about using the information from the text file to create my connection string so that my program can use it? I can't program the connection string in the project because i don't know the name of the server they will be using and they might need to put it on other servers.. Please help!! Nab

    Nab

    C P 2 Replies Last reply
    0
    • J JustmeNick

      Ok thank you guys. But can any one help me with this? My program would have a initial setup screen where the system admin will suply all the necessary informatoin such as the server name, pasword, username and stuff like that... all this information would be written to a text file somewhere on the hard drive. The program should then take the server name, user name and password from the text file to create the connection string to connect to the database (sql 2000) How do i go about using the information from the text file to create my connection string so that my program can use it? I can't program the connection string in the project because i don't know the name of the server they will be using and they might need to put it on other servers.. Please help!! Nab

      Nab

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      JustmeNick wrote:

      How do i go about using the information from the text file to create my connection string so that my program can use it?

      string.Concat() ?


      Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

      J 1 Reply Last reply
      0
      • J JustmeNick

        Ok thank you guys. But can any one help me with this? My program would have a initial setup screen where the system admin will suply all the necessary informatoin such as the server name, pasword, username and stuff like that... all this information would be written to a text file somewhere on the hard drive. The program should then take the server name, user name and password from the text file to create the connection string to connect to the database (sql 2000) How do i go about using the information from the text file to create my connection string so that my program can use it? I can't program the connection string in the project because i don't know the name of the server they will be using and they might need to put it on other servers.. Please help!! Nab

        Nab

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        JustmeNick wrote:

        pasword, username and stuff like that... all this information would be written to a text file somewhere on the hard drive

        I wouldn't leave the password out in plain text.

        J 1 Reply Last reply
        0
        • P Paul Conrad

          JustmeNick wrote:

          pasword, username and stuff like that... all this information would be written to a text file somewhere on the hard drive

          I wouldn't leave the password out in plain text.

          J Offline
          J Offline
          JustmeNick
          wrote on last edited by
          #4

          ok..but how do i develop the connection string at runtime...sql server

          Nab

          P 1 Reply Last reply
          0
          • C Colin Angus Mackay

            JustmeNick wrote:

            How do i go about using the information from the text file to create my connection string so that my program can use it?

            string.Concat() ?


            Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

            J Offline
            J Offline
            JustmeNick
            wrote on last edited by
            #5

            that doesn't say much..give a an example..plz

            Nab

            C 1 Reply Last reply
            0
            • J JustmeNick

              ok..but how do i develop the connection string at runtime...sql server

              Nab

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #6

              You concatenate the properties as Colin has said. www.connectionstrings.com[^] is a useful site to bookmark :-D

              1 Reply Last reply
              0
              • J JustmeNick

                that doesn't say much..give a an example..plz

                Nab

                C Offline
                C Offline
                Colin Angus Mackay
                wrote on last edited by
                #7

                JustmeNick wrote:

                that doesn't say much..give a an example..plz

                String.Concat works like this: String.Concat("Server=", serverName, ";Database=", databaseName) However, I don't know enough about how you need your connection string to be made up. Sorry, but if you want more then you'll have to give more. Be more explicit in your request.


                Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

                J 1 Reply Last reply
                0
                • C Colin Angus Mackay

                  JustmeNick wrote:

                  that doesn't say much..give a an example..plz

                  String.Concat works like this: String.Concat("Server=", serverName, ";Database=", databaseName) However, I don't know enough about how you need your connection string to be made up. Sorry, but if you want more then you'll have to give more. Be more explicit in your request.


                  Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

                  J Offline
                  J Offline
                  JustmeNick
                  wrote on last edited by
                  #8

                  I must have bypass that section in the book i was reading... I am just saying thank you for helping me out... now i can use this information to read from an xml file or a text file..so that the system admin will be able to configure their system when ready for use... this is what i did just for testing...and it worked like a charm..thanks to you guys... if i didn't get this part..my project would be stuck.. Dim severname As String = InputBox("Enter server name...") Dim databasename As String = InputBox("Enter database name...eg DBfhms") connectionString = String.Concat("server= " + servername.Trim + "; packet size=4096; trusted_connection=true; database= " + databasename.Trim) above is just a test run..if you notice i don't have any user name or password..i think it is much better if i let the system admin control that part from windows by adding the user to a group so only those persons in that group would be able to access the system's data.. what do u guys think..is that the right approach or should i supply a user name and a password for the connection string?.. ... Thanks again..guys..

                  Nab

                  C 1 Reply Last reply
                  0
                  • J JustmeNick

                    I must have bypass that section in the book i was reading... I am just saying thank you for helping me out... now i can use this information to read from an xml file or a text file..so that the system admin will be able to configure their system when ready for use... this is what i did just for testing...and it worked like a charm..thanks to you guys... if i didn't get this part..my project would be stuck.. Dim severname As String = InputBox("Enter server name...") Dim databasename As String = InputBox("Enter database name...eg DBfhms") connectionString = String.Concat("server= " + servername.Trim + "; packet size=4096; trusted_connection=true; database= " + databasename.Trim) above is just a test run..if you notice i don't have any user name or password..i think it is much better if i let the system admin control that part from windows by adding the user to a group so only those persons in that group would be able to access the system's data.. what do u guys think..is that the right approach or should i supply a user name and a password for the connection string?.. ... Thanks again..guys..

                    Nab

                    C Offline
                    C Offline
                    Colin Angus Mackay
                    wrote on last edited by
                    #9

                    JustmeNick wrote:

                    i think it is much better if i let the system admin control that part from windows by adding the user to a group so only those persons in that group would be able to access the system's data.. what do u guys think..is that the right approach or should i supply a user name and a password for the connection string?..

                    Yes, allowing trusted connections is more secure than adding a user name and password. Just remember that once you have your connection string to cache somewhere (in memory during the course of the application - not to disk) it and keep using the cached version. If you end up with two bits of code that create a connection string and they are in any way different (even although they evaluate to the same database with the same credentials) you won't get the benefits of connection pooling.


                    Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups