insert into sql server from excel using vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zoiparas
    New Member
    • Mar 2010
    • 1

    insert into sql server from excel using vb.net

    hi. i am using the following code in vb.net wich opens me the folder to select excel but i dont know how to import these values to sql.Any ideas?
    Thank you in advance...zoi


    Dim BatchConn As New OleDb.OleDbConn ection("Provide r=Microsoft.Jet .OLEDB.4.0; " & _
    "Data Source=" & XlsPath & "; " & _
    "Extended Properties=""Ex cel 8.0;HDR=YES;""" )

    Dim BatchAdapter As New OleDb.OleDbData Adapter("Select * from [Sheet1$]", BatchConn)
    Dim BatchDataset As New DataSet("ExcelR esults")

    BatchAdapter.Fi ll(BatchDataset )


    i would like to do in simply language : strSQL = " INSERT INTO aaaa values ("Select * from [Sheet1$]")"
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    You have filled your DataSet with data from the Excel file.
    Now all you have to do is open a connection to the SQL Server and save the data there.

    See:
    Database tutorial Part 1
    Database tutorial Part 2

    And also take a look at the MSDN documentation for the DataSet to see what's available to you :)

    -Frinny

    Comment

    Working...