Relative path reference in WebConfig.ConnectionString

后端 未结 5 1336
误落风尘
误落风尘 2020-12-15 23:12

Is it possible to specify a relative path reference in connectionstring, attachDbFileName property in a web.config?

For example, In my database is located in the App

5条回答
  •  鱼传尺愫
    2020-12-15 23:31

    Add the following attributes to the test method:

    [DeploymentItem("..\\TestSolutionDir\\TestProjedtDir\\TestDataFolder\\TestAutomationSpreadsheet.xlsx")]
    [DataSource("System.Data.Odbc", "Dsn=Excel Files;dbq=|DataDirectory|\\TestAutomationSpreadsheet.xlsx", "SpreadsheetTabName$", DataAccessMethod.Sequential)]
    

    The |DataDirctory| variable is defined by the system when it runs the test. The DeploymentItem copies the spreadsheet there. You point to the spreadsheet and to the tab within the spreadsheet that the data is coming from. Right-click on the tab to rename it to something easy to remember.

提交回复
热议问题