Results 1 to 3 of 3

Thread: Is it possible to modify the connection string when using a databound project?

  1. #1

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Is it possible to modify the connection string when using a databound project?

    If I specify a datasource for my project, It builds the Connection string. Is it possible to modify this to change the Server name programatically? I am trying to switch over to using databinding in my project, and I would like to be able to specify the Database server name on the initial load of the application.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: Is it possible to modify the connection string when using a databound project?

    If think that if close all opened connection to bd then you modify at will.
    "The dark side clouds everything. Impossible to see the future is."

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Is it possible to modify the connection string when using a databound project?

    Are you saying that you're building a Data Source in the IDE at design time and thus you're using TableAdapters to get your data? If so then each TableAdapter has its own Connection object. You need to go into the DataSet designer, select a TableAdapter and set its ConnectionModifier property to Public. That will allow you to access the Connection property of every TableAdapter in code. You should then create your new connection string in code, probably using the ConnectionStringBuilder class for your data source, then set the Connection.ConnectionString property of each of your TableAdapters. I always declare a SetConnectionStrings method that does just that, which I call from the form's Load event handler.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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