Im trying to make a simple login page using mysql and visual studio. my code is as follows
private void Login_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=USER;Initial Catalog=admin;Integrated Security=True"); // making connection
SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM Login WHERE Username='" +this.Username.Text + "' AND Password='" + this.Password.Text + "'", con);
/* in above line the program is selecting the whole data from table and the matching it with the user name and password provided by user. */
DataTable dt = new DataTable(); //this is creating a virtual table
sda.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();
MessageBox.Show("Success!");
}
else
MessageBox.Show("Invalid username or password");
}
and this is my server stuff Server
and im using freemysqlhosting to host it
heres the error
System.Data.SqlClient.SqlException (0x80131904): 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) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found
User contributions licensed under CC BY-SA 3.0