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. C#
  4. connection string

connection string

Scheduled Pinned Locked Moved C#
questiondatabasehelp
3 Posts 2 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.
  • R Offline
    R Offline
    rcwoods
    wrote on last edited by
    #1

    Hi Im havin problems with my connection to my databases. I have a default connection string hardcoded in the appconfig file. I have a main form where i use opendialog to connect to another database of my choice. Everything works fine on this form, it connects to the new selected database. BUT now as soon as i go to a child form, it seems to loose that connection to the selected database and then makes use of the default hard coded string in the appconfig file. How do i keep the new selected connection over all my forms? Please if anyone could help me..would greatly appreciate it. Thanks

    E 1 Reply Last reply
    0
    • R rcwoods

      Hi Im havin problems with my connection to my databases. I have a default connection string hardcoded in the appconfig file. I have a main form where i use opendialog to connect to another database of my choice. Everything works fine on this form, it connects to the new selected database. BUT now as soon as i go to a child form, it seems to loose that connection to the selected database and then makes use of the default hard coded string in the appconfig file. How do i keep the new selected connection over all my forms? Please if anyone could help me..would greatly appreciate it. Thanks

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      With no code we can't tell where the error is. However, if you create a static string variable in your application for the connection string and use it instead of the configuration connection string (only using the configuration string on start up) then it will likely avoid your issue.

      Need custom software developed? I do C# development and consulting all over the United States.
      If you don't ask questions the answers won't stand in your way.
      Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.

      R 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        With no code we can't tell where the error is. However, if you create a static string variable in your application for the connection string and use it instead of the configuration connection string (only using the configuration string on start up) then it will likely avoid your issue.

        Need custom software developed? I do C# development and consulting all over the United States.
        If you don't ask questions the answers won't stand in your way.
        Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.

        R Offline
        R Offline
        rcwoods
        wrote on last edited by
        #3

        Thanks for the response. Did what you said in another project, where i had programmatically created my dataset,binding source and table adapters etc. it worked 100 %. but the problem with this project is that i drag and dropped the components. And now when I call the tableadapters.fill() method on the child form, in the autogenerated designer code, it gets its connection string from

        ProjectName.Properties.Settings.Default.StaffConnectionString

        which is in the app.config file. Is this one of the limitations of using drag-and-drop components?Or is there a way of working around this? I really hope there is a way around cos this is going to require alot of recoding. Thanks again for the response..

        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