Gimeesha Gamage

Gimeesha Gamage

  • NA
  • 1
  • 1.9k

C# simple logging page Desktop application

Apr 4 2013 12:24 AM
 i'm new for programming. I designed simple loging page.code as below.

SqlConnection
con = new SqlConnection();
SqlCommand cmd = new SqlCommand("select * from loginp where username=@u and pasword=@p", con);
if (con.State == ConnectionState.Closed)
con.open();
cmd.Parameters.Add(
"@u", SqlDbType.VarChar, 50).Value = textBox1_username.Text;
cmd.Parameters.Add(
"@p", SqlDbType.VarChar, 50).Value = textBox1_passowrd.Text;
SqlDataReader dr = cmd.ExecuteReader();
if ((dr.Read() == true))
{
MessageBox.Show("Welcome User");
Form1 obj = new Form1();
obj.Show();
this.Hide();
}
else
MessageBox.Show("invalid Username and Passowrd");
dr.Close();


But I received error message as below.
Error 1 'System.Data.SqlClient.SqlConnection' does not contain a definition for 'open' G:\pro\new\new\Form1.cs 33 21 new
plz advice me to how to reslove it


Answers (3)