Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to store pdf file in sql server using vb.net and allot number for feature searching ..

is anybody now how to import pdf file in sql server

What I have tried:

i don't know how to do it .help me to solve this isssue
Posted
Updated 24-Jun-19 8:15am

1 solution

Read the file into an array of bytes and INSERT it to the DB. The DB can allocate a ID number automatically (Google for IDENTITY columns) and that can provide your "number" for searching.
VB
Dim bytes As Byte() = File.ReadAllBytes(pathToFile)

Using con As SqlConnection = New SqlConnection(strConnect)
    con.Open()

    Using cmd As SqlCommand = New SqlCommand("INSERT INTO MyTable (PDFDate) VALUES (@BD)", con)
        cmd.Parameters.AddWithValue("@BD", bytes)
        cmd.ExecuteNonQuery()
    End Using
End Using
 
Share this answer
 
Comments
Maciej Los 26-Jun-19 14:52pm    
5ed!

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