Hello Everyone, I have a Problems Regarding with the IMAGE
I create a Program That save Information of END USERS including Image... but the Image will save into Bytes.....and I have no Problem in that as you seen below..... - Dim xx As String = "insert into tbl_BorrowersInfo (accountno, sname, fname, mname, photo) values ('" & txt_AccountNo.Text & "','" & txt_SNme.Text & "','" & txt_FName.Text & "','" & txt_MI.Text & "', @photo)"
-
Dim cmd As New SqlCommand(xx, con)
-
Dim ms As New MemoryStream()
-
-
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
-
Dim data As Byte() = ms.GetBuffer()
-
Dim p As New SqlParameter("@photo", SqlDbType.Image)
-
p.Value = data
-
cmd.Parameters.Add(p)
-
cmd.ExecuteNonQuery()
-
This is My Problem i have this Search Engine that can Search information that can show the information needed from the database....... it works Nicely but I don't know how to show/Retrieve the Image from Bytes to Image itself and show it into the PictureBox1.. the code shown Below.. Please Help me.. thanks.. - con.Open()
-
Dim ab As New SqlCommand("select accountno,sname, fname, mname,photo from tbl_BorrowersInfo where accountno like '%" & searchstring & "%' or sname like '%" & searchstring & "%' or fname like '%" & searchstring & "%' or mname like '%" & searchstring & "%'", con)
-
Dim bc As SqlDataReader = ab.ExecuteReader()
-
bc.Read()
-
If bc.HasRows Then
-
-
If bc.HasRows Then
-
txt_No.Text = bc("no")
-
txt_AccountNo.Text = bc("accountno")
-
cmb_ReaderType.Text = bc("usertype")
-
txt_SNme.Text = bc("sname")
-
txt_FName.Text = bc("fname")
-
txt_MI.Text = bc("mname")
-
PictureBox1.Image = bc("photo")
-
End If()
-
con.Close()
2 5328
Hi Friend, It is simple i give sample code below i just use this next button click event to retrieve images from database you just edit as ur need, -
-
Dim da As SqlDataAdapter
-
Dim ds As New DataSet
-
dbconnection()
-
-
con.Open()
-
-
da = New SqlDataAdapter("SELECT Picture FROM imagestore", con)
-
-
da.Fill(ds)
-
-
con.Close()
-
-
Dim k As Integer = ds.Tables(0).Rows.Count
-
-
i = i + 1
-
-
If i < k Then
-
PictureBox1.Image = Image.FromStream(New MemoryStream(DirectCast(ds.Tables(0).Rows(i).ItemArray(0), Byte())))
-
Else
-
i = 0
-
PictureBox1.Image = Image.FromStream(New MemoryStream(DirectCast(ds.Tables(0).Rows(i).ItemArray(0), Byte())))
-
End If
- Public Function Byte2Image(ByVal ByteArr() As Byte) As Image
-
'will turn a byte array to an image
-
Dim ImageStream As MemoryStream
-
-
Try
-
If ByteArr.GetUpperBound(0) > 0 Then
-
ImageStream = New MemoryStream(ByteArr)
-
Return Image.FromStream(ImageStream)
-
Else
-
Return Nothing
-
End If
-
Catch ex As Exception
-
Return Nothing
-
End Try
-
-
End Function
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gator |
last post by:
Hi All,
Basically my situation is this, I have a server implemented in C++,
unmanaged code, using proprietery protocol over TCP/IP to communicate
with the cilent(c++ also).
Now, I am implementing...
|
by: Andrew Inwards |
last post by:
Can anyone tell me how to convert a byte array to a stream.?
Thanks
Andrew
|
by: Dan |
last post by:
I need to convert a byte array to a string in order to upload a binary file
with an httpWebRequest. What's the most efficient way to do such a
conversion?
|
by: Dave |
last post by:
Hi, I'm trying to convert a byte array to string
--This works...
System.BitConverter.ToString(bytes)
"EB-55-79-20-18-B2-76-4D-85-0A-93-6B-97-33-31-B8"
--This doesn't, but returns...
|
by: Terry Olsen |
last post by:
Looking for info on how to convert a byte array to a string, and string to
byte array. Thanks.
|
by: Charles Law |
last post by:
I thought this had come up before, but I now cannot find it.
I have a byte array, such as
Dim a() As Byte = {1, 2, 3, 4}
I want to convert this to an Int32 = 01020304 (hex).
If I use...
|
by: shiplu |
last post by:
I have an image which I make a byte array. Now I want to store the byte array to the database server through jsp. I have created table & query string. I am facing problem to send request to the jsp
|
by: Sergei Shelukhin |
last post by:
Hi. I receive a byte array that contains utf-16 string (with a lot of
\0 characters :)) from a legacy system that holds some data that is
changed elsewhere. How do I convert it to an actual utf-16...
|
by: MrVS |
last post by:
Hi,
I have a C++ CLR class method that takes System::Byte *b as parameter argument. I want the CSharp caller pass a byte * to this function.
But in the CSharp prorgram, I only managed to create a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |