Private Sub InsertFilenames() Using conn As New System.Data.SqlClient.SqlConnection("YourConnString") 'Build an insert string containing an INSERT statement for each item. Dim text As New System.Text.StringBuilder() For Each filename As String In System.IO.Directory.GetFiles("Path", "Filter") text.Append("INSERT INTO YourTableName (FileName) VALUES ('") text.Append(filename) 'Construct file name if needed... text.Append("' ") Next Dim cmd As New System.Data.SqlClient.SqlCommand(text.ToString(), conn) Try cmd.Connection.Open() cmd.ExecuteNonQuery() 'Handle error... Catch sqlExc As System.Data.SqlClient.SqlException Finally If cmd.Connection IsNot Nothing Then cmd.Connection.Close() End If End Try End Using End Sub
For Each filename As String In System.IO.Directory.GetFiles("Path", "Filter")<br />
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)