Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to store and retrieve PDF, Xls files into database using vb.net 2010

$
0
0

Hey guys,

Can you please tell me, how can I save pdf and xls files in sql server database using vb.net

2010. Following is the code I have used to store images into database

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim cmd As New SqlCommand("INSERT INTO Info VALUES(@name,@photo)", con)
        cmd.Parameters.AddWithValue("@name", TextBox1.Text)
        Dim ms As New MemoryStream()
        PictureBox1.BackgroundImage.Save(ms, PictureBox1.BackgroundImage.RawFormat)
        Dim data As Byte() = ms.GetBuffer()
        Dim p As New SqlParameter("@photo", SqlDbType.Image)
        p.Value = data
        cmd.Parameters.Add(p)
        cmd.ExecuteNonQuery()
        MessageBox.Show("Name & Image has been saved", "Save", MessageBoxButtons.OK) 
    End Sub
Tell me how to save pdf files into database. What should be the datatype of columns in

 
database?

   

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>