0

i really have a problem to this code. can anyone help me?

Try
            Dim fBrowse As New OpenFileDialog
            With fBrowse
                .Filter = "Excel files(*.xls)|*.xls|All files (*.*)|*.*"
                .FilterIndex = 1
                .Title = "Import data from Excel file"
            End With
            If fBrowse.ShowDialog() = Windows.Forms.DialogResult.OK Then
                Dim fname As String
                fname = fBrowse.FileName
                Dim MyConnection As System.Data.SqlClient.SqlConnection
                Dim DtSet As System.Data.DataSet
                Dim MyCommand As System.Data.SqlClient.SqlDataAdapter
                MyConnection = New System.Data.SqlClient.SqlConnection _
                ("SERVER=GEN-PC;Data Source=" & fname & ";" & "Extended Properties=""Excel 8.0;HDR=NO;IMEX=1""")
                MyCommand = New System.Data.SqlClient.SqlDataAdapter("select Columns names from [sheet$]", MyConnection)
                MyCommand.TableMappings.Add("Table", "Student")
                DtSet = New System.Data.DataSet
                MyCommand.Fill(DtSet)
                MyConnection.Close()
            End If
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
2
Contributors
1
Reply
22
Views
2 Years
Discussion Span
Last Post by Reverend Jim
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.