Click here to Skip to main content
14,387,205 members
Rate this:
Please Sign up or sign in to vote.
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
Updated 26-Dec-14 0:45am
Member 11245935 26-Dec-14 6:06am
how can i retrive from data base?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

'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())

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
MessageBox.Show("SuccessFull", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)

To Retrive A PDF

Dim filePdf As String
           filePdf = Application.StartupPath & "\" & fileNmaeYouWant & ".pdf"
           If System.IO.File.Exists(filePdf) Then
           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
                   bytesLoad = mydatatable.Rows(0).Item("pdfColumn")
               End If
               Exit Sub
           End If
           My.Computer.FileSystem.WriteAllBytes(filePdf, bytesLoad, False)
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100