1

I have a localdb database file, and my connection string to connect to it is the following (which works from the C# application):

connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\db.mdf;Integrated Security=True";providerName="System.Data.SqlClient"

I do not have an instance, as I connect directly to the data file. I would like to execute scripts on this database, as it is set up on a large number of client PCs. To run the script, I have tried connecting to the database using SqlCmd, however it cannot find the database since there is no instance. How can I connect to the file?

I have tried the following: SqlCmd.exe -S (LocalDB)\v11.0\<path to my mdf file>, however it times out as it does not find the database.

intense
  • 21
  • 1
  • You should attach the file as a registered database with yoyr LocalDB instance: http://blogs.msdn.com/b/bethmassi/archive/2008/12/18/attaching-a-local-sql-express-database-using-sqlcmd.aspx – ErikEJ Apr 30 '15 at 10:46
  • isn't this just a reworded version of the last question you asked? http://stackoverflow.com/questions/29961907/updating-once-deployed I would just edit that question if you haven't got a satisfactory answer rather than ask a new question. I'd suggest that this is a duplicate and should be deleted. – Tanner Apr 30 '15 at 10:46
  • Not really @Tanner - The previous question was asking how I can run the scripts. This question is about a particular problem when trying to use one possible approach. It is therefore more specific and not a duplicate. – intense Apr 30 '15 at 11:00
  • @intense well the answer provided didn't work, so you should probably comment to the user and state that, and they might amend their post as well as edit your original post to show what you've tried. – Tanner Apr 30 '15 at 11:02
  • I'm not sure but can you rearrange the connection string, put the integrated security before the attachdbfilename – JC Borlagdan Apr 30 '15 at 13:58

0 Answers0