Hi @StewartBW ,
You can construct SQL insert statements to insert multiple rows at once using the OleDbCommand
and OleDbParameter
classes.
Dim sqlInsert As String = "INSERT INTO YourTable (Column1, Column2, Column3) VALUES (?, ?, ?)"
Using connection As New OleDbConnection(connectionString)
connection.Open()
Using command As New OleDbCommand(sqlInsert, connection)
Using reader As New StreamReader("your_csv_file.csv")
While Not reader.EndOfStream
Dim line As String = reader.ReadLine()
Dim fields As String() = line.Split(","c) ' Assuming CSV fields are comma-separated
command.Parameters.AddWithValue("@param1", fields(0))
command.Parameters.AddWithValue("@param2", fields(1))
command.Parameters.AddWithValue("@param3", fields(2))
command.ExecuteNonQuery()
command.Parameters.Clear()
End While
End Using
End Using
End Using
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.