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


Login Form in C# using Sql Server.


Login Form in C# using Sql Server.

Author
Message
Zain -Ul- Arifeen
Zain -Ul- Arifeen
Supreme Being
Supreme Being (227 reputation)Supreme Being (227 reputation)Supreme Being (227 reputation)Supreme Being (227 reputation)Supreme Being (227 reputation)Supreme Being (227 reputation)Supreme Being (227 reputation)Supreme Being (227 reputation)Supreme Being (227 reputation)

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

2- {

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

5- }



6- private void btnlogin_Click_1(object sender, EventArgs e)

7- {

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

9- {

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

11- txtusername.Focus();

12- }

13- else

14- {



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

17- cnn.Open();

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





20- SqlDataReader dr = cmd.ExecuteReader();

21- string userText = txtusername.Text;

22- string passText = txtpassword.Text;



23- while (dr.Read())

24- {

25- if

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

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



28- {

29- frm.Show();

30- this.Hide();

31- }

32- else

33- {

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

35- }



36- }



37- dr.Close();

38- cnn.Close();
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search