I see. Being a novice at this stuff, I need to reread about that in
Francesco Balena's book. He has a chart showing the relationship between
DAO, RDO, and ADO. There is one block "Jet engine" coming from "DAO 3.5"
and going to "ODBC Driver Manager". Is "Jet engine" the same as
"Microsoft.Jet"?
Also, does the "OLE" in OLEDB" stand for Object Linking and Embedding?
Thanks,
Tony
>> Hello Richard.
>>
[quoted text clipped - 10 lines]
>
> No. "OLE DB" is the mechanism behind ADO.
> I see. Being a novice at this stuff, I need to reread about that in
> Francesco Balena's book. He has a chart showing the relationship between
[quoted text clipped - 6 lines]
> Thanks,
> Tony
To find what you need on the web this quick 40,000 foot view might help.
All database access from VB can be done by using a variety of components,
technologies, interfaces, and protocols. These components form a 'stack'.
Programming Lanugage (VB)
Data Access Library (DAO, ADO, OO4O, and RDO)
Data Provider/Driver (OLE DB, ODBC, OCI)
Database Engine (Jet, SQL Server, Oracle)
The Data (MDB, SQL Server, Oracle, ...)
Note: I included MDB (Jet formated flat-files), SQL Server (a RDBMS), and
Oracle (yet another RDBMS) to demonstrate that this applies to ALL database
access. You can pop in and out various components at either level.
In your case:
Your Code -> Uses an Data Access Library (ADO)
The Data Access Library -> Uses a Provider (OLE DB)
The Provider/Driver -> Uses a Database engine (Jet)
The Jet engine -> Uses the MDB data store (a Jet formatted file)
OLE does have roots with an early inter-process technology termed "Object
Linking and Embedding". Over time with enhancements this evolved into an
advanced IP technology with its own specification called just "OLE" (or OLE
2). It is associated with COM. COM is a distributed object specification.
OLE is Microsoft's implementation of COM. (But it isn't 'COM' - its the
machinery behind COM.)
"Jet" refers to the proprietary Microsoft Jet Database Engine. It is also
often used to refer to "Jet Formatted" database files.
When reading about any of these technologies it is important to note the
context within which the term is used - all of them can be seen from various
points of view - conceptually from its interface to something else, its
specification, rules, or methods, or as its implementation or how it works
internally. But don't try to understand everything at the beginning. Many a
programmer has done quite well working with ADO without a clue of what the
engine or provider is actually doing. That's the beauty of all these
technologies - they abstract the whole process down to a simple interface.
hth
Tony Girgenti - 27 Jan 2008 19:45 GMT
Hello Ralph.
Thanks for all of that. You certainly have a better handle on it than i do.
I tried the ADO routine that Richard supplied, but i'm having a problem with
it. It's not putting the data from the text file into the recordset. I'm
creating the recordset as i go along, then i'm executing these statements:
casInputFileConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & casInputPathString & ";" _
& "Extended Properties=""text;HDR=NO;FMT=Delimited"""
casInputFileRecordset.Open "SELECT * FROM dlcasout.csv", _
casInputFileConnection, adOpenStatic, adLockOptimistic, adCmdText
It doesn't give an error, it just doesn't give me the data.
I took it through the debugger and stopped it on the
casInputFileConnection.Open statement. The watch window shows the recordset
fields as i appended them. Once i execute the casInputFileRecordset.Open
statement, all of the field names go back to "F1", "F2", etc. and their
values are null.
That explains why the recordset does not get populated, but why is the
recordset losing all of the field names?
Any help would be gratefully appreciated.
Thanks,
Tony
>> I see. Being a novice at this stuff, I need to reread about that in
>> Francesco Balena's book. He has a chart showing the relationship between
[quoted text clipped - 50 lines]
>
> hth
Ralph - 27 Jan 2008 20:59 GMT
> Hello Ralph.
>
[quoted text clipped - 23 lines]
>
> Any help would be gratefully appreciated.
I can't see anything you are doing wrong. But occasionally VB can become
confused, especially if you have been banging around on it for a bit.
Clean your project and have another go.
Also you didn't meantion what O/S or what version of ADO you are using. If
you are using something less than XP SP2 you might want to download the
latest 'n greatest MDAC and Jet.
Here is sample code that works:
http://www.buygold.net/v05n09/v05n09.html
See if you can get it to work within your problem domain.
-ralph
Tony Girgenti - 27 Jan 2008 20:44 GMT
I have to correct what i stated in my previous reply.
The data *is* in the redordset. It's just that the field names are changed
after executing the casInputFileRecordset statement.
However, the data is not populated into the Excel workbook when i execute
this statement:
newExcelWorkSheet.Range("A2").CopyFromRecordset casInputRecordset
This whole program was working before i converted over to the ADO method of
opening the text file. Maybe there is another way to add data to the
workbook because i'm now using an ADO recordset?
Any help would be gratefully appreciated.
Thanks,
Tony
>> I see. Being a novice at this stuff, I need to reread about that in
>> Francesco Balena's book. He has a chart showing the relationship between
[quoted text clipped - 50 lines]
>
> hth
Ralph - 27 Jan 2008 21:29 GMT
> I have to correct what i stated in my previous reply.
>
[quoted text clipped - 14 lines]
> Thanks,
> Tony
My apologies. I lost focus on what you were eventually trying to do. And
wasted your time on "ADO/VB" issues. You are using VB to invoke Excel
Automation to create a Workbook.
As for the lack of a Header, you can simply add one and use a Schema.ini
file.
http://msdn2.microsoft.com/en-us/library/ms974559.aspx
Adding a header is simple enough. Create a file that contains the header and
then "Shell header.txt + dlcasout.csv dlcasout.txt (or csv)"
The schema.ini also gives you additional control over datatypes, etc.
Using Headers:
Dim Target As Range
Set Target = Target.Cells(1, 1)
Dim idx As Integer
...
For idx = 0 To rs.Fields.Count - 1
Target.Offset(0, idx).Value = rs.Fields(idx).Name
Next
TargetRange.Offset(1, 0).CopyFromRecordset rs
hth
-ralph
David mugela - 18 Jun 2008 10:47 GMT
Hi I have recently come across the same problem and wanted to ask you if your excel output was only missing some entries or was completely blank? a response would be highly appreciated. Thanks
David
Jan Hyde (VB MVP) - 18 Jun 2008 11:09 GMT
David mugela's wild thoughts were released on Wed, 18 Jun
2008 02:47:54 -0700 bearing the following fruit:
>Hi I have recently come across the same problem and wanted to ask you if your excel output was only missing some entries or was completely blank? a response would be highly appreciated. Thanks
>David
I think you meant to reply to a thread but you appear to
have started a new one.
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde