Private Sub BlobFilesToDatabase(ByVal TheFolderPath As String) 'this is a recursive function, that, after processing all the files in the current directory, digs deeper into each subfolder in the current directory. If Directory.Exists(TheFolderPath) Then Dim mySqlConnectionFormat As String = "data source={0};initial catalog={1};user id={2};password={3};Trusted_Connection=False;Connect Timeout=600;Workstation ID=GhostInTheMachine;Application Name=HaxxorPadPlusPlus;" Dim MyConn As New SqlConnection MyConn.ConnectionString = String.Format(mySqlConnectionFormat, "DEV223", "SandBox", "Noobie", "NotARealPassword") MyConn.Open() 'assuming a table like CREATE TABLE MyImages(ImageID int IDENTITY(1,1) NOT NULL PRIMARY KEY,ImageFileName varchar(50),BlobData varbinary(max) ) Dim sql As String = "INSERT INTO MyImages VALUES(@ImageFileName,@BlobData)" Dim MySqlCommand As New SqlCommand(sql, MyConn) MySqlCommand.Parameters.Add("@ImageFileName", SqlDbType.VarChar) MySqlCommand.Parameters.Add("@BlobData", SqlDbType.Image) For Each TheFilename As String In Directory.GetFiles(TheFolderPath) If TheFilename.EndsWith("jpg", StringComparison.CurrentCulture) OrElse TheFilename.EndsWith("ico", StringComparison.CurrentCulture) Then If File.Exists(TheFilename) Then Dim oFile As System.IO.FileInfo oFile = New System.IO.FileInfo(TheFilename) Dim oFileStream As System.IO.FileStream = oFile.OpenRead Dim lBytes As Long = oFileStream.Length Dim DiskBlob(lBytes - 1) As Byte ' Read the file into a byte array oFileStream.Read(DiskBlob, 0, lBytes) MySqlCommand.Parameters(0).Value = oFile.Name MySqlCommand.Parameters(1).Value = DiskBlob MySqlCommand.ExecuteNonQuery() End If End If Next 'now process any sub folders. For Each TheSubDirectory As String In Directory.GetDirectories(TheFolderPath) BlobFilesToDatabase(TheSubDirectory) Next End If End Sub