SELECT SUM(column01) FROM dbtest.table01 WHERE column02 = '" & encrypt(selectedValue, salt) & "'
问题是,数据库内的数据是经过散列/加密的,这就是无法计算数据的原因。现在我使用此查询切换到MySqlDataAdapter,我在DataGridView中显示数据(此处显示了deshahed / decrypted数据):
SELECT column01 FROM dbtest.table01 WHERE column02 = '" & encrypt(_selectedValue, salt) & "'
到目前为止,这是我的代码。
Dim dataAdapter As New MySqlDataAdapter
Dim dataTable As New DataTable
Dim bSource As New BindingSource
Try
conn.Open()
Dim query As String
query = "SELECT column01 FROM dbtest.table01 WHERE column02 = '" & encrypt(_selectedValue, salt) & "'"
command = New MySqlCommand(query, conn)
dataAdapter.SelectCommand = command
dataAdapter.Fill(dataTable)
bSource.DataSource = dataTable
DataGridView_Moon.DataSource = bSource
For i As Integer = 0 To dataTable.Rows.Count - 1
dataTable.Rows(i)("column01") = decrypt(dataTable.Rows(i)("column01"), salt)
Next
conn.Close()
Catch ex As Exception
Finally
conn.Dispose()
End Try
如果可以,请将totalValue放入消息框中。感谢