Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42732

VS 2010 incorrect syntax near's'.

$
0
0
It is frustrating

here is the code

Code:

Try
                conn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Danial\documents\visual studio 2010\Projects\ESI_PF_Payroll_V1\ESI_PF_Payroll_V1\Payroll.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
                conn.Open()
                comd.Connection = conn
                comd.CommandText = "select * from tbllogin where username = '" & txtuname.Text & "' and secretquestion = '" & ComboBox1.Text & "' and secretanswer = '" & TextBox4.Text & ";"
                rd = comd.ExecuteReader
                If rd.HasRows Then
                    rd.Read()
                    txtuname.Text = rd.Item("username")
                    ComboBox1.Text = rd.Item("secretquestion")
                    TextBox3.Text = rd.Item("secretanswer")
                    ' MessageBox.Show("Username is Valid")

                    '(+++++++++++++++++++++++++++++++++++++++++++++++++)
                    'Convert plain text into a byte array.
                    Dim TextBytes As Byte()
                    TextBytes = System.Text.Encoding.UTF8.GetBytes(TextBox2.Text)
                    Dim mySSHA256 As New System.Security.Cryptography.SHA256Managed()

                    'get the hash of the byte array, the result is a byte array as well
                    Dim ResultBytes() As Byte
                    ResultBytes = mySSHA256.ComputeHash(TextBytes)

                    'represent the hash in easy to read chars
                    Dim ResultString As String = Convert.ToBase64String(ResultBytes)

                    'MessageBox.Show(ResultString)

                    '**********************************************************************

                    ' Dim HashPasswordString As String = "hTysYulZfBiYp41QTCu37ZJbv2P+rv0/S+i+13M60+c="
                    Dim HashPasswordString As String = TextBox2.Text


                    'Convert the entered string to a byte array.
                    Dim PlainTextBytes As Byte()
                    PlainTextBytes = System.Text.Encoding.UTF8.GetBytes(TextBox2.Text)


                    Dim mySHA256 As New System.Security.Cryptography.SHA256Managed()

                    'get the hash of the byte array, the result is a byte array as well
                    Dim HashResultBytes() As Byte
                    HashResultBytes = mySHA256.ComputeHash(PlainTextBytes)

                    'represent the hash in easy to read chars
                    Dim HashResultString As String = Convert.ToBase64String(HashResultBytes)


                    'now see whether the 2 hashes match
                    If HashPasswordString = TextBox3.Text Then
                        MessageBox.Show("Password has been updated!")
                        Me.Hide()
                        Login.Show()
                    Else
                        MessageBox.Show("Password did not match!", "Unmatched Password", MessageBoxButtons.OK)
                        txtuname.Clear()
                        TextBox2.Clear()
                        TextBox3.Clear()
                        txtuname.Focus()
                    End If

                Else
                    MessageBox.Show("Username or secret question or secret answer Did not match enter a valid username,secret question,secret answer", "Data Matching Error")
                    txtuname.Clear()
                    TextBox2.Clear()
                    TextBox3.Clear()
                    txtuname.Focus()
                    rd.Close()
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try


Viewing all articles
Browse latest Browse all 42732

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>