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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.