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)
SqlConnection conn = new SqlConnection("Data Source=FAHADSHEIKHJI/FAHADSHEIKHJI;Initial Catalog=UAEExchangeShiroor;Integrated Security=True;"); public Login() { InitializeComponent(); }
private void btnLogin_Click(object sender, EventArgs e) { if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Open();//this line am getting error SqlDataReader myReader = null; SqlCommand myCommand = new SqlCommand("select * from tblLogin where logUserName='" + txtUserName.Text + "' and logPassword='" + txtPassword.Text + "'", conn); myReader = myCommand.ExecuteReader(); if (myReader.Read()) { conn.Close(); Login.ActiveForm.Hide(); Form f1 = new MDIParent1(); f1.Show(); } else { MessageBox.Show("The entered Username or Password is not correct"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)