P
Paulywog0667
Guest
Any advice for binary back to PDF from SQL with the example? Or how I'd un-hash from SQL the second example? I'm saving a bunch of fillable PDF templates to an SQL column and wrote a SELECT = a listBox.selection to query the data back, but am stuck on what's probably close to binary back to Chr(…). All the Microsoft examples seem to be generous with copy/paste C# instead of VB .NET, VB or VB console.
''''''''''''
'''prefer Binary back to PDF with the first example. They're PDF fillable forms I'm saving
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
full_file_name = TextBox1.Text
full_file_name.Split("\")
filename = full_file_name.Last.ToString
Dim conn As SqlConnection = New SqlConnection("Server=localhost;Database=templates;Trusted_Connection=True;")
Dim cmd5 As SqlCommand = New SqlCommand
cmd5.Connection = conn
cmd5.CommandText = "INSERT INTO templates (filedescription, description, content) VALUES (@file, @desc, @dat)"
With cmd5.Parameters
.AddWithValue("@file", filename)
.AddWithValue("@desc", TextBox2.Text)
.AddWithValue("@dat", SqlDbType.VarBinary).Value = File.ReadAllBytes(TextBox1.Text)
End With
conn.Open()
cmd5.ExecuteNonQuery()
conn.Close()
MsgBox("File Saved!")
TextBox1.Clear()
End Sub
'''''''''''''
'I'd prefer using the MD5s, SHA512,256, etc., for data integrity once I accomplish getting a
'file back from SQL, but if someone has anything where the result can get un-hashed from SQL
'after I run the SELECT.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myHash As SHA512 = New SHA512CryptoServiceProvider
Dim file As FileStream = New FileStream(My.Computer.FileSystem.SpecialDirectories. _
MyDocuments & "\Test.txt", FileMode.Open, FileAccess.Read)
Dim reader As BinaryReader = New BinaryReader(file)
myHash.ComputeHash(reader.ReadBytes(CType(file.Length, Integer)))
'Dim encryptstream As String = (Convert.ToBase64String(myHash.Hash))
MsgBox("Hash: " & vbCrLf + (Convert.ToBase64String(myHash.Hash)))
Dim example = (Convert.ToBase64String(myHash.Hash))
End Sub
Continue reading...
''''''''''''
'''prefer Binary back to PDF with the first example. They're PDF fillable forms I'm saving
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
full_file_name = TextBox1.Text
full_file_name.Split("\")
filename = full_file_name.Last.ToString
Dim conn As SqlConnection = New SqlConnection("Server=localhost;Database=templates;Trusted_Connection=True;")
Dim cmd5 As SqlCommand = New SqlCommand
cmd5.Connection = conn
cmd5.CommandText = "INSERT INTO templates (filedescription, description, content) VALUES (@file, @desc, @dat)"
With cmd5.Parameters
.AddWithValue("@file", filename)
.AddWithValue("@desc", TextBox2.Text)
.AddWithValue("@dat", SqlDbType.VarBinary).Value = File.ReadAllBytes(TextBox1.Text)
End With
conn.Open()
cmd5.ExecuteNonQuery()
conn.Close()
MsgBox("File Saved!")
TextBox1.Clear()
End Sub
'''''''''''''
'I'd prefer using the MD5s, SHA512,256, etc., for data integrity once I accomplish getting a
'file back from SQL, but if someone has anything where the result can get un-hashed from SQL
'after I run the SELECT.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myHash As SHA512 = New SHA512CryptoServiceProvider
Dim file As FileStream = New FileStream(My.Computer.FileSystem.SpecialDirectories. _
MyDocuments & "\Test.txt", FileMode.Open, FileAccess.Read)
Dim reader As BinaryReader = New BinaryReader(file)
myHash.ComputeHash(reader.ReadBytes(CType(file.Length, Integer)))
'Dim encryptstream As String = (Convert.ToBase64String(myHash.Hash))
MsgBox("Hash: " & vbCrLf + (Convert.ToBase64String(myHash.Hash)))
Dim example = (Convert.ToBase64String(myHash.Hash))
End Sub
Continue reading...