0

I've a connection string in my project for single mdf file as:

Private conn As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=|datadirectory|BillAdjustment.mdf;Integrated Security=True")
Private cmd As New SqlCommand

This connection works perfect on my pc but don't work on another pc and gets error:

A network related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

My database installs in appdata folder. is there any solution?

ɐsɹǝʌ ǝɔıʌ
  • 4,440
  • 3
  • 35
  • 56
  • Did you include sql server in the prerequisites before building or is there sql express or anything similar installed on thisother pc? Maybe this post will help: http://stackoverflow.com/questions/28321508/publish-a-project-with-local-database/28321997#28321997 – チーズパン May 05 '15 at 07:45
  • no i didn't, i don't know how to include. please guide. – Mirza Nauman Umar May 08 '15 at 05:46

1 Answers1

0

Try including SQL Server in the prerequisites before building.

In Solution Explorer:

Rightclick your project -> Properties -> Publish -> Prerequisites

In the Prerequisites window check SQL Server Express LocalDB (or whatever you are using):

enter image description here

This will forward the user to SQL Server download and installation during the installation of your application.

チーズパン
  • 2,752
  • 8
  • 42
  • 63