How to add multiple images to sqldb Image field

Priyantha Niroshan 21 Reputation points
2021-08-08T13:08:06.287+00:00

Dear All,
I have a SQL database call Books, containing the following fields.

ID [int]
Name varchar(50)
Author varchar(30)
Pic1 [image]
Pic2 [image]
Pic3 [image]
Active [bit]

I want to add 3 images to my SQL database using vb.NET. These images will be selected by the user via a common dialog box.

can someone help me with the sample code, please?

Thank you.
Rgds,
Niroshan.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,568 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
{count} votes

Accepted answer
  1. Viorel 112.1K Reputation points
    2021-08-08T13:52:07.23+00:00

    See how the @photo parameter is used to insert an image together with other details: https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql/inserting-an-image-from-a-file. You will have three such parameters. To load the array of bytes, use File.ReadAllBytes.

    The technique can be also used with UPDATE statement.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful