0% found this document useful (0 votes)
161 views37 pages

VB.NET: Manage Images in SQL Database

This document discusses how to insert, update, delete, search and display images stored in a SQL database using VB.Net. It explains how to add, edit and delete images from the database, search for images by ID and display images from the database in a datagridview. The document provides links to 5 YouTube video parts that demonstrate the techniques.

Uploaded by

Benny Bav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views37 pages

VB.NET: Manage Images in SQL Database

This document discusses how to insert, update, delete, search and display images stored in a SQL database using VB.Net. It explains how to add, edit and delete images from the database, search for images by ID and display images from the database in a datagridview. The document provides links to 5 YouTube video parts that demonstrate the techniques.

Uploaded by

Benny Bav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VB.

Net - Insert, Update, Delete, Search Image In SQL

How To Insert Update Delete Search Display


Images In SQL Database Using [Link]
Shares

([Link]
f1J7JNIIQF34MBY0zD1PcFlpB1dzfACLcB/s1600/[Link]%2BInsert%2BUpdate%2BDelete%2BSea
rch%2BDisplay%2BImages%2BFrom%2BSQL%[Link])

In This [Link] ([Link] Tutorial We Will


See How To :

- Add Image Into SQL Server Database


- Edit Selected Image From SQL Server Database
- Delete Selected Image From SQL Server Database
- Search Image By ID From SQL Server Database
- Show Image From SQL Server Database Into Datagridview

Using Visual Basic .NET


([Link] Programming Language.
[Link] - How To Insert Update Delete Search Display Images Fr…
Fr…

Shares
(h
tt
p:
//
sa
ve
Shares
fr
o
m
.n
et
/?
ur
l=
ht
tp
s
%
3
A
%
2
F
%
2
F
w
w
w.
y
o
ut
u
b
e.
c
o
m
%
2
F
w
at
c
Shares h
%
3
Fv
%
3
Di
0
yT
K
q
BJ
O
_
U
&
ut
m
_s
o
ur
ce
=c
hr
o
m
e
&
ut
m
_
m
e
di
di
u
m
=
e
xt
Shares e
n
si
o
n
s
&
ut
m
_c
a
m
p
ai
g
n
=l
in
k_
m
o
di
fi
er
=> Part 2 ([Link] )
Shares
(h
tt
p:
//
s
a
Shares
v
ef
r
o
m
.n
et
/?
u
rl
=
h
tt
p
s
%
3
A
%
2
F
%
2
F
w
w
w
.y
o
u
t
u
b
e.
c
o
m
%
Shares 2
F
w
at
c
h
%
3
F
v
%
3
D
y
3
p
g
6-
N
Q
7
b
Q
&
u
t
m
_s
o
u
rc
e
=
c
c
h
r
o
m
e
Shares &
u
t
m
_
m
e
di
u
m
=
e
xt
e
n
si
o
n
s
&
u
t
m
_c
a
m
p
ai
g
n
=l
in
k_
m
o
di
fi
er
=> Part 3 ([Link] )
Shares
Shares
(h
tt
p:
//
s
a
Shares
v
ef
r
o
m
.n
et
/?
u
rl
=
h
tt
p
s
%
3
A
%
2
F
%
2
F
w
w
w
.y
o
u
t
u
b
e.
c
o
m
%
Shares 2
F
w
at
c
h
%
3
F
v
%
3
D
G
Fc
gi
m
4
vI
h
U
&
u
t
m
_s
o
u
rc
e
=
c
h
r
r
o
m
e
&
u
Shares t
m
_
m
e
di
u
m
=
e
xt
e
n
si
o
n
s
&
u
t
m
_c
a
m
p
ai
g
n
=l
in
k_
m
o
di
di
fi
er
=> Part 4 ([Link] )

Shares
Shares
(h
tt
p:
//
s
a
Shares
v
ef
r
o
m
.n
et
/?
u
rl
=
h
tt
p
s
%
3
A
%
2
F
%
2
F
w
w
w
.y
o
u
t
u
b
e.
c
o
m
%
Shares 2
F
w
at
c
h
%
3
F
v
%
3
D
N
2
R
pJ
5
O
C
V
u
s
&
u
t
m
_s
o
u
rc
e
=
c
c
h
r
o
m
e
Shares &
u
t
m
_
m
e
di
u
m
=
e
xt
e
n
si
o
n
s
&
u
t
m
_c
a
m
p
ai
g
n
=l
in
k_
m
o
di
fi
er
=> Part 5 ([Link] )
Shares
Shares
(h
tt
p:
//
s
a
Shares
v
ef
r
o
m
.n
et
/?
u
rl
=
h
tt
p
s
%
3
A
%
2
F
%
2
F
w
w
w
.y
o
u
t
u
b
e.
c
o
m
%
Shares 2
F
w
at
c
h
%
3
F
v
%
3
D
n
qi
0z
j-
c
N
8
U
&
u
t
m
_s
o
u
rc
e
=
c
h
r
r
o
m
e
&
u
Shares t
m
_
m
e
di
u
m
=
e
xt
e
n
si
o
n
s
&
u
t
m
_c
a
m
p
ai
g
n
=l
in
k_
m
o
di
di
fi
er
=> Part 6 ([Link] )

Shares
Shares
(h
tt
p:
//
s
a
Shares
v
ef
r
o
m
.n
et
/?
u
rl
=
h
tt
p
s
%
3
A
%
2
F
%
2
F
w
w
w
.y
o
u
t
u
b
e.
c
o
m
%
Shares 2
F
w
at
c
h
%
3
F
v
%
3
D
Fl
q
Y
H
d
ui
M
5
g
&
u
t
m
_s
o
u
rc
e
=
c
h
h
r
o
m
e
&
Shares u
t
m
_
m
e
di
u
m
=
e
xt
e
n
si
o
n
s
&
u
t
m
_c
a
m
p
ai
g
n
=l
in
k_
m
o
di
fi
er
=> Part 7 ([Link] )

Shares
Shares

Project Source Code:

Imports [Link]
Imports [Link]
Imports [Link]

Public Class VbNet_Insert_Update_Delete_Search_Display_Images_From_SQL

Dim connection As New SqlConnection("Server= SAMSNG-PC; Database = TestDB;


Integrated Security = true")
Private Sub
VbNet_Insert_Update_Delete_Search_Display_Images_From_SQL_Load(sender As Object,
e As EventArgs) Handles [Link]

Dim command As New SqlCommand("select * from table_images", connection)


Dim adapter As New SqlDataAdapter(command)
Dim table As New DataTable()
[Link](table)

[Link] = False

[Link] = 100
Dim imgc As New DataGridViewImageColumn
[Link] = table

imgc = [Link](3)
[Link] = [Link]

End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]

Dim opf As New OpenFileDialog

[Link] = "Choose Image(*.JPG;*.PNG;*.GIF)|*.jpg;*.png;*.gif"


Shares

If [Link] = [Link] Then

[Link] = [Link]([Link])

End If

Dim ms As New MemoryStream


[Link](ms, [Link])

End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


[Link]

Dim img As Byte()


img = [Link](3).Value
Dim ms As New MemoryStream(img)
[Link] = [Link](ms)

[Link] = [Link](0).Value
[Link] = [Link](1).Value
[Link] = [Link](2).Value

End Sub

Public Sub ExecuteMyQuery(MyCommand As SqlCommand, MyMessage As String)

[Link]()

If [Link] = 1 Then
[Link](MyMessage)

Else

[Link]("Query Not Executed")


Shares
End If

[Link]()

populateDatagridview("")

End Sub

Private Sub BTN_INSERT_Click(sender As Object, e As EventArgs) Handles


BTN_INSERT.Click

Dim ms As New MemoryStream


[Link](ms, [Link])
Dim img() As Byte
img = [Link]()
Dim insertQuery As String = "INSERT INTO
Table_Images(name,description,the_image) VALUES('" & [Link] & "','" &
[Link] & "', @img )"

Dim command As New SqlCommand(insertQuery, connection)


[Link]("@img", [Link]).Value = img

ExecuteMyQuery(command, " IMage Inserted ")

End Sub

Private Sub BTN_UPDATE_Click(sender As Object, e As EventArgs) Handles


BTN_UPDATE.Click

Dim ms As New MemoryStream


[Link](ms, [Link])
Dim img() As Byte
img = [Link]()
Dim updateQuery As String = "UPDATE Table_Images SET name = '" &
[Link] & "',description = '" & [Link] & "',the_image = @img
WHERE id = " & [Link]

Dim command As New SqlCommand(updateQuery, connection)


Shares
[Link]("@img", [Link]).Value = img

ExecuteMyQuery(command, " IMage Updated ")

End Sub

Private Sub BTN_DELETE_Click(sender As Object, e As EventArgs) Handles


BTN_DELETE.Click

Dim deleteQuery As String = "DELETE FROM Table_Images WHERE id = " &


[Link]

Dim command As New SqlCommand(deleteQuery, connection)

ExecuteMyQuery(command, " IMage Deleted ")

End Sub

Public Sub populateDatagridview(valueToSearch As String)

Dim searchQuery As String = "SELECT * From Table_Images WHERE


CONCAT(name,description) like '%" & valueToSearch & "%'"

Dim command As New SqlCommand(searchQuery, connection)


Dim adapter As New SqlDataAdapter(command)
Dim table As New DataTable()
[Link](table)

[Link] = False

[Link] = 100
Dim imgc As New DataGridViewImageColumn
[Link] = table

imgc = [Link](3)
[Link] = [Link]

End Sub
Shares

Private Sub TextBoxSearch_TextChanged(sender As Object, e As EventArgs) Handles


[Link]

populateDatagridview([Link])

End Sub

Private Sub BTN_FIND_Click(sender As Object, e As EventArgs) Handles BTN_FIND.Click

Dim command As New SqlCommand("select * from table_images WHERE id = @id ",


connection)

[Link]("@id", [Link]).Value = [Link]

Dim adapter As New SqlDataAdapter(command)

Dim table As New DataTable()

[Link](table)

If [Link]() <= 0 Then

[Link]("No Data Found")

Else

[Link] = [Link](0)(0).ToString()
[Link] = [Link](0)(1).ToString()
[Link] = [Link](0)(2).ToString()

Dim img() As Byte


img = [Link](0)(3)

Dim ms As New MemoryStream(img)

[Link] = [Link](ms)
Shares

End If

End Sub
End Class

///////////////OUTPUT:

([Link]

dLviq4PcN1s/V-
pfTSqphLI/AAAAAAAAB4o/sitcjEU0dhkEt64Ue7Ad9_2qhuxqHAhRwCLcB/s1600/VbNet_Insert_U
pdate_Delete_Search_Display_Images_From_SQL.PNG)
if you want the source code click on the download button
below

Shares

([Link]

disclaimer: you will get the source code without the database script.

Download Projects Source Code

▶ Get Java Projects ([Link]


[Link])

▶ Get C# Projects ([Link]


[Link])

▶ Get [Link] Projects ([Link]


[Link])

▶ Get Java + C# + [Link] + Python Projects


([Link]
[Link])

You might also like