Load a Word Document Into A SQL BLOB with vb.net

Hello. Well the pain and swelling in my legs went down today. For that I am grateful. Last night I went through Jean’s Zune and got all the kids music off and set it up all over again. What was suppose to take 20 minutes took over an hour. Was kind of floored.

Anyway we want to load a word document into a SQL BLOB image with vb.net. This is what i came up with. For simplicity, I restricted the code to strictly this task which was a little difficult itself. Have a good day!


Join me on Facebook

Dim MyStream As New FileStream("C:\My.doc",FileMode.Open)
Dim DocLen As Integer = New FileInfo("C:\My.doc").Length
Dim MyBlob(DocLen) As Byte
Dim n As Integer = MyStream.Read(MyBlob,0,DocLen)
 
Dim MySql As Sting = "INSERT INTO MyBlobTable (MyId,MyBlob) VALUES (1,@MyBlob)"
Dim sql As New SqlCommand(MySql,MyConn)
Dim sqlp As New SqlParameter("@MyBlob",SqlDbType.Image)
sqlp.Value = MyBlob
sql.Parameters.Add(sqlp)
About these ads
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: