What I want to do is an application that uses a SQL Server 2008 database, but I can’t manage to connect to the db.
Here is my code:
public Form1()
{
InitializeComponent();
connection = new SqlConnection("Server=(local);Integrated Security=true");
connection.Open();
CreateDb();
this.FormClosed += new FormClosedEventHandler(Form1_FormClosed);
}
The error that I’m getting 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.
Verify that the instance name is
correct and that SQL Server is
configured to allow remote
connections. (provider: Named Pipes
Provider, error: 40 – Could not open a
connection to SQL Server)
I am trying to connect using windows authentication…
What am I doing wrong?
Check that TCP/IP connections are enabled in the SQL Server Configuration Manager. Also, if you have installed it as an instance, you will need to specify the server name as .\INSTANCE_NAME.