开发者

Binary read jpeg and store it in SQL Server db

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜