Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving trouble connecting C# executable to database file on remote computer
    text
    copied!<p>Using VC# I've created a staff management app that, upon its first run, is expected to query the user for the path to a (.mdf) database which will reside on a remote computer. A resulting path may be something like </p> <pre><code>string dbPath = @"P:\remoteComputer\public\StaffTool\ExamplePersonnelDatabase.mdf"; </code></pre> <p>Then I'm placing this string into a connection string template as so:</p> <pre><code>string dbConnectTemplate = @"Data Source=.\SQLEXPRESS;AttachDbFilename={0};Integrated Security=True;Connect Timeout=30;User Instance=True"; string dbConnectionString = String.Format(dbConnectionTemplate,dbPath); </code></pre> <p>Then I'm attempting to connect to the database LINQ to SQL style</p> <pre><code>ManagementDBDataContext db = new ManagementDBDataContext( dbConnectionString); </code></pre> <p>At this point, an error pop's up stating that </p> <blockquote> <p>The file "P:\remoteComputer\public\StaffTool\ExamplePersonnelDatabase.mdf" is on a network path that is not supported for database files.</p> <p>An attempt to attach an auto-named database for file P:\remoteComputer\public\StaffTool\ExamplePersonnelDatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.</p> </blockquote> <p>As I am relatively new to databases, I completely do not understand this message. And obviously, the file is not on a UNC share.</p> <p>Any ideas?</p> <hr> <p>Jim Lamb recommended that I connect to an instance of SQL server running remotely. Considering that I'm using LINQ to SQL, what refactoring do I have to do to make this happen? Other ideas still welcome - especially "push this button and everything will work" solutions.</p> <hr> <p>Another clue: A coworker said that there used to be some way to work through Control Panel->Administrative Tools->Data Sources(ODBC) so that a remote database could be viewed from my computer as if it was local. The coworker didn't know any more details besides this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload