How do I read the current path of |DataDirectory| from config settings

后端 未结 3 2155
花落未央
花落未央 2020-12-01 20:12

I\'m writing a program that requires the user to select the active database at application startup. I have a Windows Form that will list the databases stored in a sub-folder

3条回答
  •  没有蜡笔的小新
    2020-12-01 20:44

    Put this line before using the ConnectionString, TableAdapter, etc... to create the thing so called DataDirectory.

    I have just tested successfully by putting it right before TableAdapter.Fill(DataSet.DataTable);

    AppDomain.CurrentDomain.SetData("DataDirectory", @"Full path to your data folder");
    

    I cannot find where and what the DataDirectory is, because it doesn't exist so MSSQL will take the BaseDirectory of AppDomain.CurrentDomain instead.

提交回复
热议问题