• Log in or sign up for an account here: https://www.sythe.org/login

How to convert excel file to sql server express 2005 database file (mdf)

  • Thread starter Thread starter WalangAlam
  • Start date Start date
W

WalangAlam

Guest
How to convert excel file to sql server express 2005 database file (mdf)
 
just simply read the excel file then insert the data into thr sql database

if you do a simple search in goolg eyou can find code to read excel files as well as to insert data into sql
 
yes am looking for sample codes on how to do this. can anybody point me to the right direction?
 
Here it is a very simple example on how to read an excel file, once you get the data all you need is just insert it into the your sql db

more info
http://www.google.com/search?q=read...-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1

Code:
 Dim MyConnection As System.Data.OleDb.OleDbConnection

        Try

            Dim DS As System.Data.DataSet
            Dim strPath, strSheet As String

            strPath = "c:\Test.xls"
            strSheet = "Sheet1"

            Dim MyCommand As System.Data.OleDb.OleDbDataAdapter

            MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strPath & ";Extended Properties=""Excel 8.0;IMEX=1;HDR=YES;""")

            ' Select the data from Sheet1 of the workbook.

            MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [" & strSheet & "$]", MyConnection)

            DS = New System.Data.DataSet

            MyCommand.Fill(DS)

            Dim dv As DataView

            dv = DS.Tables(0).DefaultView

            DataGridView1.DataSource = dv

            MyConnection.Close()

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try
 
Runescape Gamblingrunescape gambling
Back
Top