Best way to set strongly typed dataset connection string at runtime?

后端 未结 7 1776
孤街浪徒
孤街浪徒 2021-02-20 01:19

My Windows Forms application uses a strongly typed dataset created using the designer in Visual Studio. At runtime I would like to be able to select either the live or test data

7条回答
  •  故里飘歌
    2021-02-20 02:20

    Best Solution I have found so far:

    Add another program setting which holds your preffered connection string as set by the client at runtime (eg. newConnectionString)

    then before using the Table Adapter:

    this.myTableAdapter.Connection.ConnectionString = Properties.Settings.Default.newConnectionString;
    

提交回复
热议问题