Reputation: 31
im having a problem with this everytime i run my code.. heres my code:
SqlConnection con = new SqlConnection("DataSource=SQLSERVER;Bar_login; Integrated Security = True");
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("select * from Bar_login where username = '" + txtuser.Text + "' and password ='" + txtpass.Text + "' ", con);
sda.Fill(dt);
if (dt.Rows.Count == 1)
{
MessageBox.Show("Login Succesfully");
}
else
{
MessageBox.Show("Wrong Username and Password");
}
it succesfully run but after the login process.. theres an exception
unhandled.."System.ArgumentException: 'Keyword not supported: 'datasource'.'".
can anyone help?
Upvotes: 2
Views: 1216
Reputation: 2468
There should be a space between "Data" and "Source" in your connection string. The keyword is "Data Source" and not "DataSource".
Upvotes: 5