i m using vs2010 and i have tried all the possible ways nearest to me to connect with the database from visualstudio plz help me heres the code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection cs = new SqlConnection("Data Source=Sql Server(SQLEXPRESS); Initial Catalog=school");
cs.Open();
MessageBox.Show(cs.State.ToString());
cs.Close();
}
}
}
it doesnt connet and give 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. 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)
help