G
Gert
Hi,
I need to store a array() of byte to a mysql field. I created a field in
mysql of type varbinary. But storing and retrieving gives problems.
Please help.
The
strTemp = EnDeCrypt(txt, psw)
Label1.Text = strTemp
encData = System.Text.Encoding.UTF8.GetBytes(strTemp)
Dim myconnstring As String = "host=vmge1; "
Dim conn As New MySql.Data.MySqlClient.MySqlConnection
Dim cmd As New MySql.Data.MySqlClient.MySqlCommand
Dim myDataReader As MySql.data.mysqlclient.MySqlDataReader
Dim oParameter As New MySql.Data.MySqlClient.MySqlParameter
conn.ConnectionString = myconnstring
Dim strQuery As String = "UPDATE klanten SET secret=?ArrayParameter"
Try
conn.Open()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
cmd.CommandText = strQuery
oParameter.ParameterName = "?ArrayParameter"
oParameter.DbType = DbType.Binary
oParameter.Value = strTemp
Label1.Text = strTemp
cmd.Parameters.Add(oParameter)
cmd.ExecuteNonQuery()
Catch ex As MySql.Data.MySqlClient.MySqlException
Label1.Text = "Error " & ex.Number & " " & ex.Message
End Try
Dim strQuery2 As String = "SELECT secret from klanten"
cmd.CommandText = strQuery2
myDataReader = cmd.ExecuteReader()
If myDataReader.Read Then
Dim T As String = myDataReader.GetString(0)
Label2.Text = T
End If
If Label1.Text = Label2.Text Then Label3.Text = "GELIJK" Else Label3.Text =
"ONGELIJK"
I need to store a array() of byte to a mysql field. I created a field in
mysql of type varbinary. But storing and retrieving gives problems.
Please help.
The
strTemp = EnDeCrypt(txt, psw)
Label1.Text = strTemp
encData = System.Text.Encoding.UTF8.GetBytes(strTemp)
Dim myconnstring As String = "host=vmge1; "
Dim conn As New MySql.Data.MySqlClient.MySqlConnection
Dim cmd As New MySql.Data.MySqlClient.MySqlCommand
Dim myDataReader As MySql.data.mysqlclient.MySqlDataReader
Dim oParameter As New MySql.Data.MySqlClient.MySqlParameter
conn.ConnectionString = myconnstring
Dim strQuery As String = "UPDATE klanten SET secret=?ArrayParameter"
Try
conn.Open()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
cmd.CommandText = strQuery
oParameter.ParameterName = "?ArrayParameter"
oParameter.DbType = DbType.Binary
oParameter.Value = strTemp
Label1.Text = strTemp
cmd.Parameters.Add(oParameter)
cmd.ExecuteNonQuery()
Catch ex As MySql.Data.MySqlClient.MySqlException
Label1.Text = "Error " & ex.Number & " " & ex.Message
End Try
Dim strQuery2 As String = "SELECT secret from klanten"
cmd.CommandText = strQuery2
myDataReader = cmd.ExecuteReader()
If myDataReader.Read Then
Dim T As String = myDataReader.GetString(0)
Label2.Text = T
End If
If Label1.Text = Label2.Text Then Label3.Text = "GELIJK" Else Label3.Text =
"ONGELIJK"