我有一個數據庫,其日期字段「必須」被加密。將數據加載到DataTable中並解密,然後對其執行查詢
要直接從數據庫解密,我用這個:
Dim comm As New SqlCommand()
Dim dt As New DataTable
comm.Connection = conn ' connection assignment to sql cmd
With comm
.CommandText = "SELECT * FROM EMPL ORDER BY EMPL_FIRST_NM ASC"
End With
Dim adapter As New SqlDataAdapter(comm)
adapter.Fill(dt) 'Fill DT with Query results
DataGridView1.DataSource = dt 'fill DGV
Try
For i As Integer = 0 To dt.Rows.Count - 1
dt.Rows(i)(1) = clsEncrypt.DecryptData(dt.Rows(i)(1))
dt.Rows(i)(2) = clsEncrypt.DecryptData(dt.Rows(i)(2))
And so on..
Next
Catch ex As Exception
MessageBox.Show(e.ToString())
End Try
我的情況:我需要運行鍼對特定日期範圍WHERE
條款。因此,目前在我的DGV中,列BeginDate
和EndDate
。
如果我需要撤回一個查詢,如SELECT EMPL_FIRST_NM, EMPL_LAST_NM FROM ???? WHERE BEGINDATE >= 12/21/2013
我需要查看解密的日期值。
我所看到的是這樣的:
Dim dr As DataRow() dr =
但我不知道我的具體情況。
爲了更好的視覺享受: 在我填充我DGV有(某些行略)的數據表
+-----------------------------------------------+
| EMP_ID EMP_F_NAME EMP_L_NAME BEG_DT END_DT |
+-----------------------------------------------+
| 100 John Doe 20140101 24000101|
| 200 Jake Locke 20070101 24000101|
| 300 Jim Slim 20120101 24000101|
| 400 Javier Suave 20100101 24000101|
+-----------------------------------------------+
是什麼樣子在DB:
+------------------------------------------------+
| EMP_ID EMP_F_NAME EMP_L_NAME BEG_DT END_DT |
+------------------------------------------------+
| ^##$D @3sAdfq MR% [email protected] $%@YYWEG |
| K&^[email protected] 54F#$3 L:[email protected]# %[email protected]&^ NH#%HJBR |
| [email protected]#$ RGER454 M$#Rz $%[email protected] hYE76F& |
| vfbDW[ DQWR5rf ~gE5yb #$!TDDg mHY6$1* |
+------------------------------------------------+
嘿史蒂夫,謝謝你的回答!如果我想將結果放入'DataGridView1',我的代碼將如何改變,利用'DataRow'代碼? (我知道這是另一個問題,但我覺得它仍然相關。) –