Hi, I have problem with my connection to the database generate from entity data model of Ado.Net Entity framework. I work in Console Application. My code looks like that:
public static void Main(string[] args)
{
string connectionString = "Data Source=(localdb)\v11.0;Initial Catalog=BarDatabase;Integrated Security=True";
using(SqlConnection con = new SqlConnection(connectionString))
{
string queryStatement = "SELECT TOP 5 * FROM dbo.Persons ORDER BY PersonId";
using(SqlCommand cmd = new SqlCommand(queryStatement, con))
{
DataTable customerTable = new DataTable("Top5Customers");
SqlDataAdapter dap = new SqlDataAdapter(cmd);
con.Open();
dap.Fill(customerTable);
con.Close();
}
}
Throw me a statement: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
I copy the connection string from Properties of my local database. Where I do mistake?