i am trying to save a text string that has been hashed using sha1 service provider.
when i try to store the hash to the database i get a sql error stating
"Syntax Error In UPDATE Statement"
yet i am using the exact same lines of code to do updates else where in the program.
my only clue is the base64string conversion.
here is the hash code.
and here is the udpate command, it's not pretty yet but it will be when i'm done.
when i try to store the hash to the database i get a sql error stating
"Syntax Error In UPDATE Statement"
yet i am using the exact same lines of code to do updates else where in the program.
my only clue is the base64string conversion.
here is the hash code.
Code:
Dim SHA1 As SHA1CryptoServiceProvider
Dim bytValue() As Byte
Dim bytHash() As Byte
' Create New Crypto Service Provider Object
SHA1 = New SHA1CryptoServiceProvider
' Convert the original string to array of Bytes
bytValue = _
System.Text.Encoding.UTF8.GetBytes(txtNewPass2.Text)
' Compute the Hash, returns an array of Bytes
bytHash = SHA1.ComputeHash(bytValue)
SHA1.Clear()
' Return a base 64 encoded string of the Hash value
z = Convert.ToBase64String(bytHash)
and here is the udpate command, it's not pretty yet but it will be when i'm done.
Code:
Dim connect As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPath
Dim conn As New OleDbConnection(connect)
Dim adapter As New OleDbDataAdapter
Dim sqlString As String = "SELECT * FROM tblEmployees"
adapter.SelectCommand = New OleDbCommand(sqlString, conn)
Dim cmdBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(adapter)
Dim BarCodeUpdate As New Database
Try
conn.Open()
' update the record
adapter.TableMappings.Add("Table", "tblEmployees")
adapter.Fill(BarCodeUpdate.Tables("tblEmployees"))
Dim idx As Integer
'Dim nullVal As DBNull
For idx = 0 To BarCodeUpdate.tblEmployees.Rows.Count - 1
'If BarCodeUpdate.tblMovie(idx).BarCode.ToUpper = BarCode Then
If BarCodeUpdate.tblEmployees(idx).Employee = txtUserName.Text.ToUpper Then
BarCodeUpdate.tblEmployees(idx).Password = z
End If
'End If
Next
adapter.Update(BarCodeUpdate)
BarCodeUpdate.Dispose()
adapter.Dispose()
conn.Dispose()
Catch ex As Exception
MsgBox(ex.Message)
End Try