I'm getting this error whenever I run my code:
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)
I tried using the solutions provided in the internet, however nothing seems to work. Like the one using the windows services, I can't find the "SQL SERVER (NAME)"
in the list of Services Local.
SqlConnection connect = new SqlConnection (@"Data Source = DESKTOP-766P0MJ; Initial Catalog = LoginCredentials; Integrated Security = True");
SqlDataAdapter adapt = new SqlDataAdapter("SELECT COUNT(*) FROM LoginCredentials where username = '" + txtbox_username.Text + "' AND password = '" + txtbox_password.Text + "'", connect);
DataTable dt = new DataTable(); //this is creating a virtual table
adapt.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
/* I have made a new page called home page. If the user is successfully authenticated then the form will be moved to the next form */
this.Hide();
new InternRequest().Show();
}
else
MessageBox.Show("Invalid username or password");