Results 1 to 2 of 2

Thread: Easy- From Excel to Table in Database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    16

    Easy- From Excel to Table in Database

    Hi !
    I've found an easy way to import data from excel file to a table in sql server 2000.
    Code:
    Dim excelConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.xls;Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';")
                excelConnection.Open()
                Dim ExcelCommand As New System.Data.OleDb.OleDbCommand("INSERT INTO [ODBC;Driver={SQL Server};Server=Servername;Database=databasename;Uid=username;Pwd=password].[tablename] SELECT * FROM[sheet1$];", excelConnection)
    
                ExcelCommand.ExecuteNonQuery()
                excelConnection.Close()
    Comments and suggestions are welcome
    Last edited by Hack; Feb 6th, 2009 at 07:48 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Easy- From Excel to Table in Database

    Moved To The CodeBank

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width