ODBC persistent link

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

ODBC persistent link

Post by mightycpa » Mon Jan 12, 2004 4:14 pm

Hi,

I've looked at the ODBC via VB script on the page, and I'm going to try it out, but I already see one need for change.

The subroutine CONNECTS, QUERIES, CLOSES ... In my application, I'm going to do something like this:

BEGIN DBRECORD LOOP

Query DB
Select
Pass value back to MS

BEGIN DBCOLUMN LOOP
Do stuff to record
Put it in another application
NEXT DBCOLUMN

NEXT DBRECORD

So, rather than re-connect each time I need a new record, ideally, the connection would occur outside of the BEGIN DBRECORD LOOP, and would persist throughout the execution of the macro. I expect the # of records to be about 4000, and the number of columns to be about 15 per record.

Can it be done?

Is this as simple as taking the connection part and placing it outside of the loop (close too?)

Should I care which way I get the job done?

Tx,

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

For clarity

Post by mightycpa » Mon Jan 12, 2004 4:16 pm

For clarity,

BEGIN DBRECORD LOOP

--Query DB
--Select
--Pass value back to MS

--BEGIN DBCOLUMN LOOP

----Do stuff to record
----Put it in another application

--NEXT DBCOLUMN

NEXT DBRECORD
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jan 13, 2004 6:50 am

When passing values back to MS, maybe write them to an INI file using VB commands, and then have Macro Scheduler read the INI file contents for processing after all VB processing is done?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Jan 13, 2004 8:39 am


Can it be done?

Is this as simple as taking the connection part and placing it outside of the loop (close too?)
Yes, like you say, put the connection part into it's own Sub, the disconnection into another sub. Put the loop in another Sub. Any variables that they all need would need to be global, so Dim them above the first Sub.

VBSTART
Dim RecordsetA
Dim SomeVar

Sub ConnectProc
bla bla bla
Set RecodsetA ....
End

Sub ReadRecord
bla bla bla
End

Sub DisconnectProc
bla bla bla
End

VBEND

VBRun>ConnectProc
//Either loop here, or have the loop all in ReadRecord .. whatever you want
VBRun>ReadRecord
//Do something else then disconnect at end
VBRun>DisconnectProc
MJT Net Support
[email protected]

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Thanks!

Post by mightycpa » Tue Jan 13, 2004 2:55 pm

Thanks both!
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts