saving picture in DB

  • Thread starter Thread starter zafar
  • Start date Start date
Z

zafar

hi, how to save an imge in Database, can any body help me for this...
thanx
 
Hi

1) Ensure the field is an image field in your table in the database

In your app

2) declare a byte array

3) read the picture into the byte array see FileStream class
as below


Dim fs As New FileStream("c:\yourimage.jpg", FileMode.OpenOrCreate,
FileAccess.Read)
ReDim mydata(fs.Length)
fs.Read(mydata, 0, fs.Length)
fs.Close()

4) in the datatable set the row to the byte array

do the update as normal

hope this helps

Regards
Adam
 
zafar said:
hi, how to save an imge in Database, can any body help me for this...

How To Read and Write BLOB Data by Using ADO.NET with Visual Basic .NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;308042>

HOW TO: Read and Write a File to and from a BLOB Column by Using ADO.NET and
Visual Basic .NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;316887>

HOW TO: Read and Write a File to and from a BLOB Column by Using Chunking in
ADO.NET and Visual Basic .NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;317034>

HOW TO: Read and Write BLOB Data by Using ADO.NET Through ASP.NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;326502>

..NET Framework Developer's Guide -- Writing BLOB Values to a Database
<URL:http://msdn.microsoft.com/library/en-us/cpguide/html/cpconwritingblobvaluestodatabase.asp>
 
Zafar,

Please don't repeat your message. If there is a question than do it, I gave
you a sample how to read from adn add to a database and even somethings
more.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top