Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB?
Read excel file without excel installed using VB? Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Go Back  Xtreme Visual Basic Talk > > > Read excel file without excel installed using VB?


Reply
 
Thread Tools Display Modes
  #1  
Old 02-27-2012, 05:54 PM
Paco75 Paco75 is offline
Newcomer
 
Join Date: Feb 2012
Location: Quebec, Canada
Posts: 4
Default Read excel file without excel installed using VB?


Hi,

I tried to read excel file using the method i found here Using ADO with Excel files

But i get an error on ADODB.Connection saying "Type 'ADODB.Connection' is not defined" in the following code:

Code:
Private Function GetExcelConnection(ByVal Path As String, _
    Optional ByVal Headers As Boolean = True) As Connection
    Dim strConn As String
    Dim objConn As ADODB.Connection
    Set objConn = New ADODB.Connection
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & Path & ";" & _
              "Extended Properties=""Excel 8.0;HDR=" & _
              IIf(Headers, "Yes", "No") & """"
    objConn.Open strConn
    Set GetExcelConnection = objConn
End Function
Its was used in VB6... do i need to do something special in Visual Studio 2010? What is wrong in this code?
Reply With Quote
  #2  
Old 02-28-2012, 09:06 AM
DrPunk's Avatar
DrPunkRead excel file without excel installed using VB? DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

ADO isn't part of .NET. It's old COM stuff.

This MSDN article shows how to use ADO in .NET -> http://support.microsoft.com/kb/315974

You only need to do the references part because you just need access to the ADODB Recordset.
__________________
There are no computers in heaven!
Reply With Quote
  #3  
Old 02-29-2012, 07:55 PM
Paco75 Paco75 is offline
Newcomer
 
Join Date: Feb 2012
Location: Quebec, Canada
Posts: 4
Default

thanks here is the connection procedure that i used. Works fine with excel 2010

Code:
Private Function GetExcelConnection(ByVal Path As String, Optional ByVal Headers As Boolean = True) As Connection
        Dim strConn As String
        Dim objConn As ADODB.Connection
        objConn = New ADODB.Connection
        strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                  "Data Source=" & Path & ";" & _
                  "Extended Properties=""Excel 8.0;HDR=" & _
                  IIf(Headers, "Yes", "No") & """"
        objConn.Open(strConn)
        GetExcelConnection = objConn
End Function
then to use the connection
Code:
Dim objConnExcel As New ADODB.Connection
Dim strRequestExcel As String
Dim objRSExcel As New ADODB.Recordset

objConnExcel = GetExcelConnection("D:\myExcelFile.xls", False)
strRequestExcel = "SELECT * FROM [Sheet1$]"
objRSExcel.Open(strRequestExcel, objConnExcel)
If i want to connect to a MySQL 5.5 database what would be the connection string?
Reply With Quote
  #4  
Old 03-01-2012, 02:25 AM
Flyguy's Avatar
FlyguyRead excel file without excel installed using VB? Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,165
Default

Reply With Quote
  #5  
Old 03-02-2012, 06:50 AM
Paco75 Paco75 is offline
Newcomer
 
Join Date: Feb 2012
Location: Quebec, Canada
Posts: 4
Default

Thanks very useful site
Reply With Quote
  #6  
Old 03-02-2012, 07:27 AM
DrPunk's Avatar
DrPunkRead excel file without excel installed using VB? DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

If you're gonna connect to MySQL then use the .NET stuff rather than sticking to recordsets.
__________________
There are no computers in heaven!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Read excel file without excel installed using VB? Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB? Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
 
Read excel file without excel installed using VB?
Read excel file without excel installed using VB?
 
-->