So here is my first attempt at a ADO code to read the text from .txt File ( with pipe, _ | _ , separators )
Clearly it has been done a lot before, but the syntaxes all seem a bit different and jumbled up...
I am almost there... This Post is and attempt by me in a fairly light hearted and from a Layman’s view point to explain what the “ADO way” is all about..
If you are one of the gifted few that understand everything already, then you might want to skip this and go to the next post, where I run more briefly through a specific example run and discuss some remaining issues....
Here is a description of the basic codes I have done ...
( The codes I have here from about Post # 290 to post # 296 https://www.excelforum.com/developme...ml#post4641842 https://www.excelforum.com/developme...ml#post4643062 )
Introduction General code approach Function and calling Sub routine.
It suits me to do a Function, but..
For this thread I will keep the code “standalone” for the benefit of future reference for anyone lurking this post. So to aid that I have a calling Sub routine , Sub TestieInputTextADO()
That Sub routine takes into the Function as main argument the Full Path and File name of the text file. A few other things, some optional are also taken it:_..
the FullPathandFileName of the text file that I want to get my data out of, ____ strFullPathAndFileName
an array As somewhere to Refer the data, ( the data from text file is put in this) arrBk()
the separator ( I use typically a __ | _ ) , _________________________ Sep
and then three Optional arguments for info on the Header and range of data I might want.
( The last three arguments I may experiment a bit with, and the separator still has some issues. )
Introduction getting at the programming processes of the ADO form...
General approach ( The following dribble is a bit light hearted based on what I learnt recently in the other thread... but it helps me get a feel for what is going on...
)
This is all background stuff in attempt to explain what an “ADO” code is as opposed to any other sort.
Rem 1) ADO
So in this code version I want go partly outside of Excel to use a Windows application program interface (API) to do with having a sort of active at the time database. These API programs are often supplied , for example with Windows. ( The idea is that people will agree to keep their software “callable through these interface programs, regardless of if they change them , so that you have a better chance of using them through this route as directly )
But I am still fundamentally in Excel, or at least Excel VBA, ( and personally am not too clued up on how to use directly these API things.. ) ...
So .. what is available to me ???
There is since about the 1990’s an openly available database connectivity (ODBC) application program interface but I want something a bit more optimum for Office stuff, .. - a bit more in the direction of object orientated programming.
Microsoft have done some object linking and embedding database (OLEDB) programs , but they are not so easy for an end user to get at and use.
So Microsoft did try to make their Excel Files generally more compatible and readable with the internationally agreed structural query language ( SQL) for databases , and about that time they also tried to come up with something that would somehow work with those commands on various of the API’s and similar software. By this time all the computer Graduates were already totally confused. They had no idea where what they were doing fitted in anywhere, and started using terms like “ Driver “ , “ engine “ or “ provider “ just to fill in the missing spaces in sentences: Think of what drives a car. The driver or the engine. Who is the provider of, or driver of what. Is the engine belonging to? - the car, a series of cars, a series of engines, and even so, it can be used, whether or not planned originally , to drive something else ..They got mixed up with what opening turning on and connecting meant also ... Hmm.. .. Well, So .. then .. Microsoft .. also tried to come up with something that would somehow work with those commands on various of the API’s and similar software:...They came up with a new name ...
joint .. “engines” .. for want of a better word .. programming technologies (JET) for “driving” .. for want of a better word these things.. ( A bit later they did some similar stuff and optimised it a bit towards Microsoft ACCESS, and called it Access Connectivity Engine (ACE) )
So what I need is a way of getting to use the oledb from Microsoft through the Microsoft Jet . Pseudo I need
________ Jeton _ . _ oledb
So I need to have access, in my VBA object orientated programming environment of some library if possible which will give me things like objects which will let me present initially some statement in an object orientated hierarchy stylio of pseudo
Microsoft’s . Jeton . OLEDB . XXX activeopenedatthetimemytextFile ; and argumentsto ; ; pass in sql Format:=
I need ideally a suite of objects in a Library to make this main “connection” as it were, _..
1 (ii) ObjConnect ___ ”{ Microsoft’s . Jeton . OLEDB . X C: \ \ \mytextFile.txt ; _ ; _ ; ; }”
( I want to then apply that to my database, so the objects I need will have to associate or refer to my active X .xx Q&*?&%* database data object database. ) _..followed by some processing on that “opened up active at the time” database... or working with that ObjConn*** ... So a general area of interest to me now, and many people previously, is/ was active database objects.. so there is the word ADO. I think I know what I might be talking about now
##
There seems to be one available , an Microsoft ActiveX Data Objects 2.5 ,
1 (i) ADO DataBase Objects so in my code I will add reference to that by putting a check against it under Tools -- References , and look for some ADO DB type things/ objects... of the form I am looking for....
I expect I need initially like a main thing / object to do some sort of
ADO DB connection of / laying wide open a active “highway / route – the previous:
1 (ii) ObjConnect __ ”{ Microsoft’s . Jeton . OLEDB . X C: \ \ \mytextFile.txt ; ; ; }” = ObjConnected/OpenedTurnOn
1 (ii) ObjConn _ . _ TurnOnOpenConnect___ ”{ ___ JET.OLEDB.Info On File }” = ObjConnected/OpenedTurnedOn
( “Hey” , said Bill Gates , “Quick, let’s call that “{ __ }” a connection string just to keep them all confused )
Then I expect I need another object that is not much more than a set of data , a subset or all of what is available. I expect this object, whilst a VBA / OOP compatible thing, to have integrated into it a lot of, if not all possible SQL commands. The SQL commands I expect to be needed somehow to define the what data I want.
1 (iii) Set/Open DataSet _ sqlcmd _ ObjConnected/OpenedTurnedOn
Rem 2) Do stuff with the RecordDataSubSet , RuedtrSet
_.............Googling and playing around I seem to have all what I am looking for ..... all my made up names seem to actually exist in the Microsoft ActiveX Data Objects 2.5 Library ......
The only thing Microsoft got wrong in there naming was Recordset. I can see no reason why not to call it DataSet or RecordAndFieldSet.
But I guess with all the random use of words they use having forgot what they meant, (if they ever did mean anything) , then I guess we should be relieved they got any where...
_............
Next post, the same, a bit simplified... and more details to the actual first code attempt which .. well sort of works..
Bookmarks