troubleshooting Question

Perform an SQL Server Batch Insert Using .NET

Avatar of DeniseGoodheart
DeniseGoodheart asked on
.NET Programming
2 Comments1 Solution441 ViewsLast Modified:
Good Day:

I am using VS.NET 2005 with VB.NET and SQL Server 2000.  I need to perform an SQL Server batch insert using an array that may contain 200 or more records.  How would I do this using the following code that creates a dataset called dataset1,a table called table1, and an array called mysarray?  The following is my code:

Private Sub GetFiles()
        Dim dir As New IO.DirectoryInfo(Me.txtDirLocation.Text)
        Dim files As IO.FileInfo() = dir.GetFiles("*.pdf")
        Dim fileName As IO.FileInfo
        Dim dataset1 As New DataSet
        Dim table1 As New DataTable


        For Each fileName In files
            Dim myarray() As String = Nothing
            Array.Resize(myarray, 1)
            Dim sPDFName As String = fileName.ToString
                   myarray.SetValue(sPDFName, 0)
            table1.LoadDataRow(myarray, True)
    End Sub

Thank You,

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros