Results 1 to 3 of 3

Thread: Application Startup Switches

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Location
    Glasgow, Scotland
    Posts
    77

    Application Startup Switches

    Hi all

    I've got an winforms application, written in VB.NET 2002, which retrieves information from and populates information to a SQL Server 2000 database.

    Ideally I'd like to make it possible to use the same application for both the live system, and the training system (the training system would write to a replica of the database, which would mean that any training or test records would never be reported on). Is there a way of specifying switches that you can use when launching the application, which can then be used to identify which database should be written to?

    TIA

    Ian
    Wise man once said: "Don't ever get married, just find a woman you don't like and buy her a house".
    According to ancient Chinese proverb, "Man with hole in pocket feels cocky all day".

  2. #2
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651

    Re: Application Startup Switches

    uk_codemonkey

    If you've asked this question you probably have your database connection string hardcoded into your application. I suggest you read about application configuration settings so that you understand how to stored your database connection strings outside the compiled application.
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

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

    Re: Application Startup Switches

    As Mr.No suggests, you can store you connection string in the config file and then either alter the connection string itself or comment lines in and out. If you do want to use commandline arguments then you can do somthing like this:
    VB Code:
    1. If Array.IndexOf(Environment.GetCommandLineArgs(), "-t") = -1 Then
    2.     'Use production mode.
    3. Else
    4.     'Use training mode.
    5. End If
    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