473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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...

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Private Sub btn_PilihFileExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_PilihFileExcel.Click
  3.         ListBox_DaftarSelectedFiles.Items.Clear()
  4.         txt_FileDirektori.Clear()
  5.         OpenFileDialog_ExcelStart.InitialDirectory = "C:\"
  6.         OpenFileDialog_ExcelStart.Multiselect = True
  7.         OpenFileDialog_ExcelStart.Filter = "Excel files (*.xls or *.xlsx)|*.xlsx;*.xls"
  8.         OpenFileDialog_ExcelStart.RestoreDirectory = True
  9.         OpenFileDialog_ExcelStart.Title = "Pilih File dari Logger RCS (File Excel)"
  10.         If (OpenFileDialog_ExcelStart.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
  11.             ' Read the files
  12.             Dim DaftarFile As String
  13.             Dim onlyfilename As String
  14.             For Each DaftarFile In OpenFileDialog_ExcelStart.FileNames
  15.                 onlyfilename = Mid(DaftarFile, InStrRev(DaftarFile, "\") + 1)
  16.                 ListBox_DaftarSelectedFiles.Items.Add(onlyfilename)
  17.                 txt_FileDirektori.Text = Mid(DaftarFile, 1, InStrRev(DaftarFile, "\"))
  18.             Next
  19.         ElseIf (System.Windows.Forms.DialogResult.Cancel) Then
  20.             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)")
  21.  
  22.         End If
  23.  
  24.     End Sub
  25.  
  26.     Private Sub btn_EksekusiProgram_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_EksekusiProgram.Click
  27.         Dim XL As Object, InstallAddIn As Object
  28.         XL = CreateObject("Excel.Application")
  29.         XL.Workbooks.Add()
  30.         InstallAddIn = XL.AddIns.Add("C:\Users\Linda Fitriani\Documents\latihan kondisi\macro_PrereqFiles.xla", True)
  31.         InstallAddIn.Installed = True
  32.         XL.Quit()
  33.         XL = Nothing
  34.  
  35.         XL = CreateObject("Excel.Application")
  36.  
  37.         For Each DaftarFile In OpenFileDialog_ExcelStart.FileNames
  38.             XL.Workbooks.Open("C:\Users\Linda Fitriani\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.XLSB")
  39.             XL.Workbooks.Open(DaftarFile)
  40.             XL.Visible = True         'See what is going on?
  41.             XL.Run("PERSONAL.XLSB!Macro_PrereqFiles")
  42.             'Save as varFile & "_2.xls"  (strip .xls from strExcelFile)
  43.             'Example: C:\Test\Stock_Quotes.xls will be Saved As C:\Test\Stock_Quotes_2.xls
  44.             Dim FileResult As String
  45.             FileResult = Microsoft.VisualBasic.Left(DaftarFile, Len(DaftarFile) - 5) & "_2.xlsx"
  46.             XL.ActiveWorkBook.SaveAs(FileResult)
  47.             'XL.Quit
  48.             XL.ActiveWorkbook.Close(False)
  49.             '===================================================================================
  50.             Dim _conn As String
  51.             Dim ds1 As New DataSet
  52.             Dim rpt As New CrystalReport()
  53.             _conn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & FileResult & ";" & "Extended Properties=Excel 8.0;"
  54.             Dim _connection As OleDbConnection = New OleDbConnection(_conn)
  55.             Dim da As OleDbDataAdapter = New OleDbDataAdapter()
  56.             Dim _command As OleDbCommand = New OleDbCommand()
  57.             _command.Connection = _connection
  58.             _command.CommandText = "SELECT * FROM [Import$]"
  59.             da.SelectCommand = _command
  60.  
  61.             Try
  62.                 da.Fill(ds1, "Import")
  63.                 MessageBox.Show("The import is complete!")
  64.                 'Me.DataGridView1.DataSource = ds1
  65.                 'Me.DataGridView1.DataMember = "Import"
  66.             Catch e1 As Exception
  67.                 MessageBox.Show("Import Failed, correct Column name in the sheet!")
  68.             End Try
  69.         Next
  70.         ' Close Excel.
  71.         XL.Quit()
  72.         XL = Nothing
  73.     End Sub
  74. End Class
Attached Files
File Type: xlsx rec-10.xlsx (14.0 KB, 423 views)
File Type: xlsx rec-11.xlsx (14.0 KB, 426 views)
File Type: zip macro_PrereqFiles.zip (8.9 KB, 127 views)
Jan 9 '12 #1

✓ answered by lindafitriani

SOLVED

by using

Imports System
Imports System.Data
Imports System.Data.OleDb

haha, stupid me :D
:) thank u...

1 5417
SOLVED

by using

Imports System
Imports System.Data
Imports System.Data.OleDb

haha, stupid me :D
:) thank u...
Jan 9 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: B R | last post by:
Hi, I am trying to use System.DirectoryServices for quering Active Directory, I am getting the following error Compiler Error Message: BC30002: Type 'DirectoryEntry' is not defined. Why I...
2
by: Charax | last post by:
I'm a newbie with VS.NET I'm trying the test application at http://support.microsoft.com/default.aspx?scid=kb;en-us;308278 My first attempt to connect to an external database results in the...
7
by: CJM | last post by:
I'm finally taking my first few steps with ASP.NET, and I'm just workign my way through some of the basics. As a vehicle for my learning, I'm re-writing a simple report page for on of my ASP...
2
by: David Lozzi | last post by:
This script is in the code-behind. This is a repost of a reply in "Name 'IsNumeric' is not declared??'. I wanted to post it under a different subject. Type 'EventArgs' is not defined at Sub...
6
by: bokiteam | last post by:
Hi All, I have this error msg, but I have already import lib, could you please advice? Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form Dim cn As...
1
by: Lew Burrus | last post by:
I am relatively new to advanced concepts in OOP, though I am fairly comfortable working in .Net. Have recently taken a 1.1 project into VS2005, and came across a show-stopper of an error. When...
4
by: uche | last post by:
Hello, I am having a problem with my code in C++/C. I have struggled for a while and cannot find the solution to the problem... Here is the compiled..output: In file included from disk.cpp:8:...
2
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I think if the object type of the control is not System.Windows.Forms.xxx, then it is a user-defined control. But how to tell the type of the user-defined control: Composite(User), Extended, and...
0
by: ardas111 | last post by:
Language :: VS.NET/ C# The type 'frm_data.frm_data' is defined in an assembly that is not referenced. You must add a reference to assembly I have a Frm_sol solution, which consists on 2...
3
by: ma79ash | last post by:
Language :: VS.NET/ C# The type 'frm_data.frm_data' is defined in an assembly that is not referenced. You must add a reference to assembly I have a Frm_sol solution, which consists on 2...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.