Hi,
Im making a simple program which converts a encrypted text file the upload it to sql CE.
This is time in and out logs of every employee. The date is extracted from a machine and downloaded as encrypted file.
We managed to decrypt it by getting the equivalent value of each character.
I need to decrypt this file then save it to database (sql server 2008 r2)
Downloaded file looks like this, in plain text:
±²®ªÇª®°°®°®¯±ª®·¸²®¸±²B
´µ³ªÇª®°°®°®¯±ª®·¸²±¸³®N
´µ³ªÍª®°°¯°®¯±ª¯·¸®°¸²²T
±²®ªÍª®°°¯°®¯±ª°®¸®®¸°®9
±¯´ªÍª®°°¯°®¯±ª°®¸®®¸±²A
´µ³ªÇª®°°°°®¯±ª®·¸±¶¸±´X
±¯´ªÇª®°°°°®¯±ª¯®¸²¯¸²´C
±²®ªÇª®°°°°®¯±ª¯®¸²±¸°µA
´µ³ªÍª®°°°°®¯±ª¯·¸±¶¸±²]
´µ³ªÇª®°°³°®¯±ª®·¸³¯¸²µX
My code for now in uploading: (I used openfiledialog object to open the file)
cmd = New SqlCeCommand("Create Table TempDb (Rec Nvarchar (100)) ", Con)
cmd.ExecuteNonQuery()
Dim cmd2 As SqlCeCommand
Using MyReader As New StreamReader(ofdBrowse.FileName)
Dim fields As String()
Dim line As String
While Not MyReader.EndOfStream
line = MyReader.ReadLine
'Dim line As String = My.Computer.FileSystem.ReadAllText(ofdBrowse.FileName)
fields = line.Split(vbNewLine)
For Each field As String In fields
Select Case field
Case "®"
ch = "0"
Case "¯"
ch = "1"
Case "°"
ch = "2"
Case "±"
ch = "3"
Case "²"
ch = "4"
Case "³"
ch = "5"
Case "´"
ch = "6"
Case "µ"
ch = "7"
Case "¶"
ch = "8"
Case "·"
ch = "9"
Case "Ç"
ch = "I"
Case "Í"
ch = "O"
Case "«"
ch = "-"
Case "ª"
ch = ","
Case ""
ch = "/"
Case "¸"
ch = ":"
End Select
rec = rec & ch
Next
cmd2 = New SqlCeCommand("Insert Into TempDb (Rec) Values (@r)", Con)
cmd2.Parameters.AddWithValue("@r", rec)
cmd2.ExecuteNonQuery()
End While
End Using
adap = New SqlCeDataAdapter("Select * From TempDb", Con)
Dim dt As New DataTable
adap.Fill(dt)
If dt.Rows.Count > 0 Then
dgTime.DataSource = dt
End If
cmd = New SqlCeCommand("Drop Table TempDb", Con)
cmd.ExecuteNonQuery()
There is no error but the uploaded data is empty. Its not null in database, just nothing (empty string)
any other approach is grately appreciated
After uploading the decrypted file, how to download or export it back to text file? ready for uploading to different program
Thanks