fiogf49gjkf0d Scott, as others have mentioned, your method is not the best approach. Not knowing whether your database contains 1 row of 1M could ultimately doom this to failure! What you are suggesting is essentially "take EVERYTHING and throw it into a file" as a datastream. Even if this does work - you've got almost zero chance of having anything the other side understand what you did!
However, to answer your question directly - I wish you all the best with the rest of it !
1) Ensure you include the SLX script "System:SLX Database Support" - this is the cause of the 1st issue - SLX DB is undefined (it's defined in this script, and when included - it sets up many of the functions you'll need) 2) You do not have a loop 3) ts.WriteLine strSQL - will do exactly that - your file will end up with "SELECT * FROM ACCOUNT" in it (which isn't what you were expecting!) 4) You're not handling any form of formatting (but, I guess you'll do that later right?) 5) Beware BLOBS. The Account table contains a column called NOTES. This is a BLOB/MEMO field - and contain upto 2GB of data ! XL will just panic with that 6) If you have more than XXX rows - beware XL97 will not handle 32,767 rows (vastly increased in later versions - but still limited)
As for your general code, you'll need to alter this as follows:
#Include: SLX Database Support, SLX Error Support
Dim objSLXDB, objRS, strSQL, i Set objSLXDB = New SLX_DB
Set objRS = objSLXDB.GetNewRecordSet ' Create an object (objRS) containing result set of sql supplied
strSQL = "Select ACCOUNT From ACCOUNT Where TYPE = 'Active'" ' sql you want to execute
objRS.Open strSQL, objSLXDB.Connection ' Open a connection, execute SQL and name it objRS
With objRS ' Work with object - means you can just use "." instead of entire name For i = 0 To .RecordCount - 1 ' Loop If Not (.BOF And .EOF) Then ' Check not at end/beginning
msgbox .Fields("ACCOUNT").Value ' do something here e.g.
ts.WriteLine .Fields("ACCOUNT").Value
.MoveNext ' Move to next record End If Next .Close End With
Set objRS = Nothing ' Clean up
The above executes a SQL command, gets a recordset, uses a loop to work through the returned RS and then does something of your bidding. If it were me, I'd specify the cols required and then perhaps loop through those columns, using an index (instead of a name) e.g. ts.WriteLine .Fields(ix).Value where ix is the index of the column.
I think you have a way to go before this'll begin to look usable. But, the above will at least get you started !
Regards Mike
|