Help vb 2010: type OledbConnection, OledbAdapter, and OledbCommand is not defined RRS feed

  • Question

  • I'm trying to import data excel (*.xlsx) to reportview... but i'm getting stuck for six hours to solve this problem :
    type OledbConnection, OledbAdapter, and OledbCommand is not defined

    i also couldn't find any reference named Microsoft Jet OledB 4.0 in my visual studio 2010 ......... but i find Microsoft

    Jet and Replication Object 2,6 Library... i added it to my reference , but it didn't work to solve my problem

    my question is : where can i download reference to Microsoft Jet OledB 4.0... is there any mistakes in my installation

    package visual studio 2010?

    once, i got message that type "crystalreport" is not defined, probably because i use visual studio 2010 that's not include

    crystal report in their package installer, and i decided have to download it as 3rd party..

    here my codes so far... i'm not finished it yet to the report view... i was stuck in this "type not defined error"

    here i attached also my files ( my macro.xla (zipped in *.zip), and some excel files to execute)

    please help me, i would appreciate any help...

    Public Class Form1
        Private Sub btn_PilihFileExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
            OpenFileDialog_ExcelStart.InitialDirectory = "C:\"
            OpenFileDialog_ExcelStart.Multiselect = True
            OpenFileDialog_ExcelStart.Filter = "Excel files (*.xls or *.xlsx)|*.xlsx;*.xls"
            OpenFileDialog_ExcelStart.RestoreDirectory = True
            OpenFileDialog_ExcelStart.Title = "Pilih File dari Logger RCS (File Excel)"
            If (OpenFileDialog_ExcelStart.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
                ' Read the files
                Dim DaftarFile As String
                Dim onlyfilename As String
                For Each DaftarFile In OpenFileDialog_ExcelStart.FileNames
                    onlyfilename = Mid(DaftarFile, InStrRev(DaftarFile, "\") + 1)
                    txt_FileDirektori.Text = Mid(DaftarFile, 1, InStrRev(DaftarFile, "\"))
            ElseIf (System.Windows.Forms.DialogResult.Cancel) Then
                MsgBox("You must select one or more file to import before proceeding (Program tidak akan berjalan jika tidak 
    ada file yang dipilih)", vbOKOnly + vbExclamation, "No file Selected, exiting (Keluar Program)")
            End If
        End Sub
        Private Sub btn_EksekusiProgram_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
            Dim XL As Object, InstallAddIn As Object
            XL = CreateObject("Excel.Application")
            InstallAddIn = XL.AddIns.Add("C:\Users\Linda Fitriani\Documents\latihan kondisi\macro_PrereqFiles.xla", True)
            InstallAddIn.Installed = True
            XL = Nothing
            XL = CreateObject("Excel.Application")
            For Each DaftarFile In OpenFileDialog_ExcelStart.FileNames
                XL.Workbooks.Open("C:\Users\Linda Fitriani\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.XLSB")
                XL.Visible = True         'See what is going on?
                'Save as varFile & "_2.xls"  (strip .xls from strExcelFile)
                'Example: C:\Test\Stock_Quotes.xls will be Saved As C:\Test\Stock_Quotes_2.xls
                Dim FileResult As String
                FileResult = Microsoft.VisualBasic.Left(DaftarFile, Len(DaftarFile) - 5) & "_2.xlsx"
                Dim _conn As String
                Dim ds1 As New DataSet
                Dim rpt As New CrystalReport()
                _conn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & FileResult & ";" & "Extended Properties=Excel 
                Dim _connection As OleDbConnection = New OleDbConnection(_conn)
                Dim da As OleDbDataAdapter = New OleDbDataAdapter()
                Dim _command As OleDbCommand = New OleDbCommand()
                _command.Connection = _connection
                _command.CommandText = "SELECT * FROM [Import$]"
                da.SelectCommand = _command
                    da.Fill(ds1, "Import")
                    MessageBox.Show("The import is complete!")
                    'Me.DataGridView1.DataSource = ds1
                    'Me.DataGridView1.DataMember = "Import"
                Catch e1 As Exception
                    MessageBox.Show("Import Failed, correct Column name in the sheet!")
                End Try
            ' Close Excel.
            XL = Nothing
        End Sub
    End Class


    Monday, January 9, 2012 5:14 PM