none
Switching DataSet Assignment RRS feed

  • Question

  • I'm sorry, I have no idea which forum this question would belong to.

    I have a project which collects data from a SQL database and saves it to a text file. Part of the process is updating a field in the database, so that row will be ignored in the future.

    The program is executed using "scheduled tasks" on the server. Since, it is run in "background," I developed a Console application in VS2013. The VS program uses data sets and table adapters.

    The program works correctly. And here is the problem. I have TWO databases. One for development, one for production. The development database is identical to the production one. The names are slightly different. I am looking for a way to switch from one database to the other as simply as possible. This way, after I am done developing and testing the application, I can change the program to use the production database, compile one more time, and put the resulting program into production. Does anyone have an idea?

    Thursday, October 2, 2014 2:33 PM

Answers

  • I don't think I am using the SQLConnection class. I set the connection when I created the DataSet.

    I did find how to set the Project.Properties.Settings. Of course the only setting I had was t he connection string. So, based on the value of the command line parameter (which for production is nothing) I can adjust the connection string. Seems to be working correctly in my tests.

    Thanks for the nudges in the right direction.

    • Marked as answer by wodders Friday, October 3, 2014 1:43 PM
    Friday, October 3, 2014 1:43 PM

All replies

  • Why don't you implement a command line switch which will determine which database you are going to use? It sounds like a very simple problem to me.

    Are you using C#?

    Thursday, October 2, 2014 2:56 PM
  • I am using C#. I will look at command line switches. I guess I am also unsure how to dynamically refer to the database. Parameter into the data set?

    I find that most of the questions I ask involve a simple fact or technique I am not aware of how to implement in VS. Unfortunate result of being new to VS.

    Thursday, October 2, 2014 3:29 PM
  • I guess I am also unsure how to dynamically refer to the database. Parameter into the data set?


    It depends somewhat on what technique you are using to connect to the SQL database. If you use a SQLConnection class, for example, you would set the ConnectionString property to the appropriate connection string. Typically one would define a connection string for each database and store the string in the App.config file. Take a look at this MSDN document and see if it makes sense to you.
    Thursday, October 2, 2014 7:37 PM
  • I don't think I am using the SQLConnection class. I set the connection when I created the DataSet.

    I did find how to set the Project.Properties.Settings. Of course the only setting I had was t he connection string. So, based on the value of the command line parameter (which for production is nothing) I can adjust the connection string. Seems to be working correctly in my tests.

    Thanks for the nudges in the right direction.

    • Marked as answer by wodders Friday, October 3, 2014 1:43 PM
    Friday, October 3, 2014 1:43 PM