saving images into sql-server from VB.NET 
Author Message
 saving images into sql-server from VB.NET
How does one save an image file to a SQL Server Database
using VB.NET?



Tue, 30 Nov 2004 02:46:40 GMT  
 saving images into sql-server from VB.NET
Here is a C# example:
http://www.dotnetbips.com/displayarticle.aspx?id=60

You should be able to follow the basic gist of the example and translate to
VB.NET.

This one just deals with displaying the images, but it is in VB.NET:
http://www.dotnetbips.com/displayarticle.aspx?id=101

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think outside the box!
****************************************************************************
****

Quote:
> How does one save an image file to a SQL Server Database
> using VB.NET?



Tue, 30 Nov 2004 03:28:16 GMT  
 saving images into sql-server from VB.NET
In addition to the articles posted by Gregory Beamer, here's some
pseudo-code that may help... Basically, the idea is to take the picture,
read it into a stream and into a byte array which you assign to the column.

Imports System.IO
Dim FileName As String
FileName = "C:\test.jpg"

Dim fs As New FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Read)

' Read the Data into the Byte Array
Dim MyData(fs.Length) As Byte
fs.Read(MyData, 0, CType(fs.Length, Integer))
fs.Close()

' Assign the DataRow Picture Column to the Byte Array to populate it in the
DataRow
Dim aRow As System.Data.DataRow
aRow("Picture") = MyData

' Add the DataRow to the DataTable
Dim TheTable As System.Data.DataTable
TheTable.Rows.Add(aRow)

' Write all the data (including the picture) to the Flashcards Sql Server
database
Dim sqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Dim ds As System.Data.DataSet

sqlDataAdapter1.Update(ds, "Table")
MessageBox.Show("Data Added.")

End Sub

Hope this helps!

yag
--

Yair Alan Griver
Lead PM/Evangelist
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> How does one save an image file to a SQL Server Database
> using VB.NET?



Tue, 30 Nov 2004 04:09:49 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Saving images to SQL Server using VB.net

2. Save image in Sql Server and retrieve image from sqlserver to vb

3. Save Image To SQL Server

4. Saving Word documents and Crystal reports as images in a SQL Server database

5. Saving Images in SQL Server DB

6. Saving BMP files in SQL Server image fields

7. Saving Binary files on the Client to the Image data type in SQL Server

8. How save JPG file in SQL Server image or binary field

9. Saving an Image into SQL server?

10. Saving images in a SQL Server DB using ADO

11. Saving an image from picture box to sql server

12. How to save a Image to SQL Server

 

 
Powered by phpBB® Forum Software