Click here to Skip to main content
Sign Up to vote bad
good
See more: VB.NET
i m making electronic paper system
how can i compare textbox fields with SQL database values on my login button?
Posted 5 Jan '13 - 0:28

Comments
GeekforChrist - 5 Jan '13 - 8:39
Do you have any knowledge of SQL or are you looking for complete code?

3 solutions

How can i compare textbox fields with SQL database values on my login button?
Steps:
1. On login button press, raise the click event. Write your comparison code here in this click handler.
2. Now, using ADO.NET, connect to database. Form a query for comparison of the value in DB
3. Run the query and get back the result
4. Take action based on the result returned.
 
Few references that would help:
MSDN: Accessing Data with ADO.NET[^]
Using ADO.NET for beginners[^]
Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]
  Permalink  
Comments
Espen Harlinn - 6 Jan '13 - 9:25
Nice links :-D
Sandeep Mewara - 6 Jan '13 - 10:11
Thanks Espen.
Mika Wendelius - 6 Jan '13 - 10:57
Good examples!
SQL database values on my login button
Please don't do this yourself, use ASP.NET Authentication[^].
 
Security is a thorny issue which requires an in depth understanding of a wide range of technologies. ASP.Net provides authentication and authorization out of the box, so there is no need to implement this yourself.
 
Best regards
Espen Harlinn
  Permalink  
Comments
Mika Wendelius - 6 Jan '13 - 10:58
Good point!
Espen Harlinn - 6 Jan '13 - 10:59
Thank you, Mika :-D
 
con.con_open()
 
        Dim cmdlogin As New SqlCommand(("SELECT * FROM users WHERE user_name='" & _
                                            txtuname.Text & "' and password='" & _
                                            txtpassword.Text & "'"), con.con)
        Dim dalogin As New SqlDataAdapter
        Dim dslogin As New Data.DataSet
        dalogin.SelectCommand = cmdlogin
        cmdlogin.ExecuteNonQuery()
        dslogin.Clear()
        dalogin.Fill(dslogin, "users")
 

        If dslogin.Tables(0).Rows.Count > 0 Then
 
        Else
            
        End If
 
'--------------------or

        if txtusername.text=dslogin.Tables(0).Rows(0).Item(0).ToString then
 
        else
 
        end if
 
'--------------------

        con.con_close(
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 423
1 OriginalGriff 291
2 Mayur_Panchal 153
3 Mohammed Hameed 145
4 Dave Kreskowiak 125
0 Sergey Alexandrovich Kryukov 8,146
1 OriginalGriff 6,236
2 CPallini 3,482
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid