Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


C#


Poll
Login Form using Sql server in c#. Closed Poll

100% - 1 vote i am using this code . but give me Error in this statement
100% 1 vote
0% - 0 votes SqlDataReader dr = cmd.ExecuteReader();
0% 0 votes
0% - 0 votes or
0% 0 votes
0% - 0 votes Messagebox("Invalid User or Wrong Password").
0% 0 votes
0% - 0 votes Anyone Can help me in this code.
0% 0 votes
Member Votes: 1, Guest Votes: 0. You don't have permission to vote within this poll.
Author
Message
Zain -Ul- Arifeen
Zain -Ul- Arifeen
Forum Guru
Forum Guru (149 reputation)Forum Guru (149 reputation)Forum Guru (149 reputation)Forum Guru (149 reputation)Forum Guru (149 reputation)Forum Guru (149 reputation)Forum Guru (149 reputation)Forum Guru (149 reputation)Forum Guru (149 reputation)

Group: Forum Members
Posts: 3, Visits: 13
private bool CompareStrings(string string1, string string2)

    {

    return String.Compare(string1, string2, true, System.Globalization.CultureInfo.InvariantCulture) == 0 ? true : false;

    }



private void btnlogin_Click_1(object sender, EventArgs e)

{

if (txtusername.Text == "" || txtpassword.Text == "")

{

MessageBox.Show("Please Fill All The Details", "Zain -Ul- Arifeen");

txtusername.Focus();

}

else

{



cnn.ConnectionString = "Data Source=zain\\SqlExpress;Initial Catalog=Studentinformationsystem;Integrated Security=true";

cnn.Open();

SqlCommand cmd = new SqlCommand("SELECT username,password FROM login WHERE username='" + txtusername.Text + "' and password='" + txtpassword.Text + "'", cnn);





SqlDataReader dr = cmd.ExecuteReader();    

    string userText = txtusername.Text;

    string passText = txtpassword.Text;



    while (dr.Read())

    {

if

(this.CompareStrings(dr["username"].ToString(), txtusername.Text) &&

    this.CompareStrings(dr["password"].ToString(), txtpassword .Text ))



    {

frm.Show();

this.Hide();

    }

    else

    {

MessageBox.Show("Invalid User or wrong Password", "Zain -Ul- Arifeen");

    }

   

    }

   

    dr.Close();

cnn.Close();
Admin
Admin
Administrator
Administrator (2.1K reputation)Administrator (2.1K reputation)Administrator (2.1K reputation)Administrator (2.1K reputation)Administrator (2.1K reputation)Administrator (2.1K reputation)Administrator (2.1K reputation)Administrator (2.1K reputation)Administrator (2.1K reputation)

Group: Administrators
Posts: 81, Visits: 1.2K
Why was this posted as a poll? Please re-post as a new topic.


Best regards,

Forum Administrator
A1VBCode



GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search