Can't connect to SQL Server database, visual studio and sql server on my computer

  • Thread starter Thread starter pavlob
  • Start date Start date
P

pavlob

Guest
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Database
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Button1_Click(object sender, EventArgs e)
{
string connetionString;
SqlConnection cnn;
connetionString = @"Data Source=N201462857\SQLEXPRESS";

cnn = new SqlConnection(connetionString);
cnn.Open();
MessageBox.Show("Connection open ! ");
}
}
}
System.Data.SqlClient.SqlException: '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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)'

Continue reading...
 
Back
Top