Adblock breaks this site

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

Discussion in 'Programming General' started by WalangAlam, May 8, 2007.

  1. WalangAlam

    WalangAlam Guest

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

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

    dodge Active Member
    Banned

    Joined:
    Mar 26, 2007
    Posts:
    125
    Referrals:
    1
    Sythe Gold:
    5
    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
     
  3. WalangAlam

    WalangAlam Guest

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

    yes am looking for sample codes on how to do this. can anybody point me to the right direction?
     
  4. dodge

    dodge Active Member
    Banned

    Joined:
    Mar 26, 2007
    Posts:
    125
    Referrals:
    1
    Sythe Gold:
    5
    How to convert excel file to sql server express 2005 database file (mdf)

    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
     
< Thank you | Learning by Examples >


 
 
Adblock breaks this site