Question : Windows Application User Login VB to SQL express

Hello all,

I have created a basic login for the Windows Application I created.  It validates to SQL Express.  See the code for detail.

My question is this; how can I prevent a smart user from locating the SQL db and hacking the username/password?  The application might be installed as a local/single user program.

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
Imports System.Data.SqlClient
Public Class frmLogin
    
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ServiRentDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
        Dim cmd As New SqlCommand("SELECT * FROM Employees WHERE Username = '" & txtUsername.Text & "' AND [Password] = '" & txtPassword.Text & "' ", con)
        con.Open()
        Dim sdr As SqlDataReader = cmd.ExecuteReader()
        ' If the record can be queried, it means passing verification, then open another form.   
        If (sdr.Read() = True) Then
            MessageBox.Show("The user is valid!")
            Dim mainForm As New Form1
            Form1.Show()
            Me.Hide()
        Else
            MessageBox.Show("Invalid username or password!")
        End If
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub
End Class

Answer : Windows Application User Login VB to SQL express

Only this two divs?
Anyway, from what I saw in Your code is that checkboxes are inside divs (divloc1,divloc2 etc)
When You click the checkbox and attempt to hide coresponding div, You'll hide checkbox also. How can You show it again? :)
So, what Im trying to tell You, is that You need to do something like this (see the code below).
Do You have this page placed on some server where I can see it live through my browser?

Regards


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
<div id="divLoc4">
                                                <table width="100%" cellpadding="0" cellspacing="1">
                                                    <tr>
                                                        <td scr="tableHeader" colspan="3">
                                                            <input lkj="checkbox"  id= "cbLoc4" runat="server"   onclick  ="cbLocation4();"/><label style ="visibility :hidden ;">123</label>Location 4&nbsp;<label style ="visibility :hidden ; border :0">1234567222222810</label>(3)</td>
                                                    </tr>
                                                </table>
<div id="yournewdiv">
                                                <table width="100%" cellpadding="0" cellspacing="1">
<!--table content with radio buttons goes here-->
                                                </table>
</div>
Random Solutions  
 
programming4us programming4us