开发者

Binary read jpeg and store it in SQL Server db

开发者 https://www.devze.com 2022-12-16 05:19 出处:网络
I have a jpeg file in my开发者_开发技巧 C drive from my vb.net application I want to binary read it and store it in SQL server.

I have a jpeg file in my开发者_开发技巧 C drive from my vb.net application I want to binary read it and store it in SQL server. How can I do that? Thanks


You can read a file into a byte array by calling File.ReadAllBytes.

You can then put the byte array into SQL Server using a SqlParameter.

For example:

Using command As New SqlCommand("INSERT INTO sometable VALUES(@image)", connection)
    command.Parameters.AddWithValue("image", File.ReadAllBytes(path))
    command.ExecuteNonQuery()
End Using
0

精彩评论

暂无评论...
验证码 换一张
取 消