Good day.
I'm busy with a new website, but I am caught in a slight tangle.
How can I set up my data source in my web.config file to access the database listed in App_Data?
Here is what I tried. I am a little rusty with detached databases.
<connectionStrings>
<add name="Careers" providerName="System.Data.SqlClient" connectionString="AttachdbFilename=../|DataDirectory|/Careers_30March.mdf;user instance=true;Integr开发者_开发技巧ated Security=true;"/>
</connectionStrings>
This was my result:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
All I need is to access this database. I know how to read connection strings from the web.config to create a SqlConnection
object. No usernames / passwords were allocated to this database.
Do take a look at this page. There are multiple examples on what can and cannot be used.
精彩评论