views:

133

answers:

2

I was once told that instead of having to have my host register a SQL Server database file + user/password it is possible instead to put my MDB file into my website's APP_DATA and connect to it directly. How do I do this?

I tried using the SqlConnection's connection wizard and set DataSource : Microsoft SQL Server Database File (SqlClient) Database file name : Path to a non-existent file in my App_Data folder. Authentication : (tried both windows and SQL server)

I click OK, at which point I am asked if I wish to create the file or not, I select "Yes". Then I experience this message:


Microsoft Visual Studio


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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)


OK


I have SQL Server 2005 installed. Is there something I am missing?

+2  A: 

I hope you mean .MDF file?

The full path to the filename is in the connection string. Something like:

Server=localhost;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;

Jeremy
Yes, MDF :-)But why is this connection dialog failing with this error? If I am expecting it to work then surely this dialog should at least succeed in creating the MDB file first?
Peter Morris
+1  A: 

Off-hand, I think what they're talking about is MS SQL Express.

John Christensen