G
Guest
I have gotten this to work for a single image load in SQL server, can anyone
help me make this a "For...Each" statement to include every file in the
folder?
on the 4th line of the main code, is the file path i made, all i need to do
now is cycle through, get "3A_00184", "3A_00191", "41033496", etc from the
folder "IMAGES"
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim cn As New SqlConnection(strCn)
Dim cmd As New SqlCommand("INSERT INTO BLOBS (BLOBDetails) " &
"VALUES (@BLOBDetails)", cn)
Dim strBLOBFilePath As String = "C:\FilePath\IMAGES\3A_00184"
Dim fsBLOBFile As New FileStream(strBLOBFilePath, FileMode.Open,
FileAccess.Read)
Dim bytBLOBData(fsBLOBFile.Length() - 1) As Byte
fsBLOBFile.Read(bytBLOBData, 0, bytBLOBData.Length)
fsBLOBFile.Close()
Dim prm As New SqlParameter("@BLOBDetails", SqlDbType.VarBinary, _
bytBLOBData.Length, ParameterDirection.Input, False, _
0, 0, Nothing, DataRowVersion.Current, bytBLOBData)
cmd.Parameters.Add(prm)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
End Sub
help me make this a "For...Each" statement to include every file in the
folder?
on the 4th line of the main code, is the file path i made, all i need to do
now is cycle through, get "3A_00184", "3A_00191", "41033496", etc from the
folder "IMAGES"
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim cn As New SqlConnection(strCn)
Dim cmd As New SqlCommand("INSERT INTO BLOBS (BLOBDetails) " &
"VALUES (@BLOBDetails)", cn)
Dim strBLOBFilePath As String = "C:\FilePath\IMAGES\3A_00184"
Dim fsBLOBFile As New FileStream(strBLOBFilePath, FileMode.Open,
FileAccess.Read)
Dim bytBLOBData(fsBLOBFile.Length() - 1) As Byte
fsBLOBFile.Read(bytBLOBData, 0, bytBLOBData.Length)
fsBLOBFile.Close()
Dim prm As New SqlParameter("@BLOBDetails", SqlDbType.VarBinary, _
bytBLOBData.Length, ParameterDirection.Input, False, _
0, 0, Nothing, DataRowVersion.Current, bytBLOBData)
cmd.Parameters.Add(prm)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
End Sub