I've been trying for a few hours now to setup a local database in my new app.
I created a new local database (project->add->local database), defined the table columns and primary keys.
Then I've moved to the Data source explorer to create a new connection to the DB.
But whenever I try to connect to the DB it says:
"A network-related or instance-specific error occurred while establishing a connection to SQL server. The server was not found or was not accessible...."
This is my initial code just for the connection:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.SqlClient;
namespace WindowsFormsApplication4
{
static class Program
{
[STAThread]
static void Main()
{
string constr = WindowsFormsApplication4.Properties.Settings.Default.Database1ConnectionString;
try
{
SqlConnection con = new SqlConnection(constr);
con.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
I'd really appreciate a little help here, I've tried to Google this question without any success.
Is the value on your ConnectionString correct/valid?Debug it and confirm.