Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
plz show me some way to develop some kind of application look like the above questions and i like to get free source code
someone plz help me
Posted
Updated 25-Dec-14 23:45pm
v2
Comments
Member 11245935 26-Dec-14 6:06am    
how can i retrive from data base?

1 solution

VB
'Add A Sql Column With Data Type varbinary
Dim fd As OpenFileDialog = New OpenFileDialog()
'fd.Filter = "pdf file|*.pdf"
If fd.ShowDialog = Windows.Forms.DialogResult.OK Then
    'Interaction.MsgBox("File saved into database", MsgBoxStyle.Information)
End If
sqlStr = ""
sqlStr = ""


Dim fs As New FileStream(fd.FileName, FileMode.Open, FileAccess.Read)

Dim br As New BinaryReader(fs)

Dim bytes As Byte()

bytes = System.IO.File.ReadAllBytes(fd.FileName)

'insert the file into database

strConn = New SqlConnection(oCommon.DSN())
strConn.Open()

sqlStr = ""
sqlStr = "update YourTable set Columns = @Columns WHERE Column =      '" & detgrd(detgrd.Row, 0).ToString().ToUpper().Trim() & "' "
SqlCmd = New SqlCommand
SqlCmd.CommandText = sqlStr
SqlCmd.Parameters.Add("@Columns ", SqlDbType.Binary).Value = bytes
SqlCmd.Connection = strConn
SqlCmd.ExecuteNonQuery()
MessageBox.Show("SuccessFull", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)



To Retrive A PDF

VB
Dim filePdf As String
           filePdf = Application.StartupPath & "\" & fileNmaeYouWant & ".pdf"
           If System.IO.File.Exists(filePdf) Then
               File.Delete(filePdf)
           End If
           Dim bytesLoad As Byte()
           bytesLoad = Nothing
           sqlStr = ""
           sqlStr = "select pdfColumn from yourtable where  "' "
           mydatatable = New DataTable
           mydatatable = modFunctions.ReturnData(sqlStr)
           If mydatatable.Rows.Count > 0 Then
               If IsDBNull(mydatatable.Rows(0).Item("pdfColumn")) = True Then
                   Exit Sub
               Else
                   bytesLoad = mydatatable.Rows(0).Item("pdfColumn")
               End If
           Else
               Exit Sub
           End If
           My.Computer.FileSystem.WriteAllBytes(filePdf, bytesLoad, False)
           System.Diagnostics.Process.Start(filePdf)
 
Share this answer
 
v2
Comments
Member 11245935 26-Dec-14 6:43am    
ho can i retrive pdf file from database?
Member 10540150 3-Jan-15 5:15am    
i have updated solutions
Kev Paras 1-May-18 7:40am    
Hi, Member 10540150, can i know what is modFunction in your solution at line mydatatable = modFunctions.ReturnData(sqlStr)?
i'm stuck with this. I'm using mysql.
Thanks in advance!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900