jvcoach23
Well-known member
I need to read an image into a datasets table. I have found an example and am trying to learn more about it.. but when I run this.. I get an access denied error . Here is the code.
and what Im using to call this
when i step through, my access denied error happens on the dim fs as new system.... line. The value coming from the dataset in teh vcFileName column is p01983.jpg. d:\Image is an actaul path.. inside that path is the image file. I am logged in as Administrator of this box and that path is local to my machine. can someone help me understand what Im doing wrong and right it please.
thanks
shannon
Code:
Public Shared Sub LoadAllImages(ByVal MyDataTable As DataTable, ByVal FilePathField As String, ByVal ImageField As String)
loop through all the rows and load the images
For Each dr As DataRow In MyDataTable.Rows
LoadImage(dr, ImageField, dr.Item(FilePathField))
Next
End Sub
Public Shared Sub LoadImage(ByVal MyDataRow As System.Data.DataRow, ByVal FilePath As String, ByVal ImageField As String)
Dim fs As New System.IO.FileStream(FilePath, IO.FileMode.Open, System.IO.FileAccess.Read)
Dim Image(fs.Length) As Byte
fs.Read(Image, 0, fs.Length)
fs.Close()
MyDataRow.Item(ImageField) = Image
End Sub
Code:
LoadAllImages(ds.Tables(0), "vcFileName", "d:\Image")
thanks
shannon