Click here to Skip to main content
15,922,533 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow to get PID,VID from an USB device ? Pin
ArjunMK22-Apr-08 8:07
ArjunMK22-Apr-08 8:07 
QuestionUnable to debug dll Pin
Trevortni22-Apr-08 6:43
Trevortni22-Apr-08 6:43 
GeneralI :heart: Microsoft Pin
Trevortni23-Apr-08 10:11
Trevortni23-Apr-08 10:11 
GeneralAccess db autonumber Pin
ziperzappper22-Apr-08 5:57
ziperzappper22-Apr-08 5:57 
GeneralRe: Access db autonumber Pin
Mycroft Holmes22-Apr-08 14:40
professionalMycroft Holmes22-Apr-08 14:40 
GeneralRe: Access db autonumber Pin
ziperzappper24-Apr-08 11:59
ziperzappper24-Apr-08 11:59 
Questionpicturebox databinding programatically Pin
JMS7622-Apr-08 5:50
JMS7622-Apr-08 5:50 
GeneralRe: picturebox databinding programatically Pin
John_Adams22-Apr-08 19:57
John_Adams22-Apr-08 19:57 
Hi Jason,

Please know that Images are stored in database as BLOB short for Binary Large OBject, a collection of binary data stored as a single entity in a database management systems (DBMS). BLOBs are used primarily to hold multimedia objects such as images, videos, and sound, though they can also be used to store programs or even fragments of code. Not all DBMSs support BLOBs.

Therefore, to read or write an image we need to use array of Byte. Below is a code snippet to read an image from a database and to show it on a picture box.

----------------------------------------------------------------------------------------------------
BEGIN CODE

' Construct a SQL string and a connection object
Dim sql As String = "SELECT UserPhoto FROM Users"
Dim conn As OleDbConnection = New OleDbConnection
conn.ConnectionString = connectionString
' Open connection
If conn.State <> ConnectionState.Open Then
conn.Open()
End If
Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
Dim fs As FileStream
Dim bw As BinaryWriter
Dim bufferSize As Integer = 300000
Dim outbyte(300000 - 1) As Byte
Dim retval As Long
Dim startIndex As Long = 0
Dim pub_id As String = ""
Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)
' Read first record
reader.Read()
fs = New FileStream(savedImageName, FileMode.OpenOrCreate, FileAccess.Write)
bw = New BinaryWriter(fs)
startIndex = 0
retval = reader.GetBytes(0, 0, outbyte, 0, bufferSize)
bw.Write(outbyte)
bw.Flush()
' Close the output file.
bw.Close()
fs.Close()
reader.Close()
' Display image
curImage = Image.FromFile(savedImageName)
PictureBox1.Image = curImage
PictureBox1.Invalidate()
' Clean up connection
If conn.State = ConnectionState.Open Then
conn.Close()
' Dispose connection
conn.Dispose()
End If
End Sub

END CODE
----------------------------------------------------------------------------------------------------

Hope this helps Smile | :) .

Regards,
John Adams
ComponentOne LLC

QuestionRe: picturebox databinding programatically Pin
JMS7623-Apr-08 5:48
JMS7623-Apr-08 5:48 
QuestionHow i can change System's Date format at run time in vb.net? Pin
r_mohd22-Apr-08 2:29
r_mohd22-Apr-08 2:29 
GeneralRe: How i can change System's Date format at run time in vb.net? Pin
John_Adams22-Apr-08 3:40
John_Adams22-Apr-08 3:40 
GeneralRe: How i can change System's Date format at run time in vb.net? Pin
darkelv22-Apr-08 4:29
darkelv22-Apr-08 4:29 
GeneralRe: How i can change System's Date format at run time in vb.net? Pin
Paul Conrad22-Apr-08 4:59
professionalPaul Conrad22-Apr-08 4:59 
QuestionHow to save and read data in and from Application.myapp file Save Pin
monafr8122-Apr-08 0:18
monafr8122-Apr-08 0:18 
GeneralFile saving/moving query Pin
Dalek Dave21-Apr-08 23:37
professionalDalek Dave21-Apr-08 23:37 
GeneralRe: File saving/moving query Pin
ChandraRam22-Apr-08 0:46
ChandraRam22-Apr-08 0:46 
GeneralTcpListener problem Pin
shee_dee8621-Apr-08 21:54
shee_dee8621-Apr-08 21:54 
GeneralRe: TcpListener problem Pin
Anoop Brijmohun22-Apr-08 3:09
Anoop Brijmohun22-Apr-08 3:09 
Questionregarding TableLayoutPanel control in vb.net 2.0 Pin
vijaylumar21-Apr-08 21:54
vijaylumar21-Apr-08 21:54 
Generaldisabled item in checkedlistbox Pin
helelark12321-Apr-08 21:44
helelark12321-Apr-08 21:44 
GeneralRe: disabled item in checkedlistbox Pin
C1AllenS22-Apr-08 4:47
C1AllenS22-Apr-08 4:47 
GeneralRe: disabled item in checkedlistbox Pin
helelark12322-Apr-08 19:26
helelark12322-Apr-08 19:26 
QuestionUpdating a control's text from another class...? Pin
Gadjuka21-Apr-08 21:21
Gadjuka21-Apr-08 21:21 
GeneralRe: Updating a control's text from another class...? Pin
Christian Graus21-Apr-08 21:23
protectorChristian Graus21-Apr-08 21:23 
GeneralRe: Updating a control's text from another class...? Pin
Gadjuka21-Apr-08 22:13
Gadjuka21-Apr-08 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.