en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en en en en de tr en en en en nl en en en en en en en en en en en nl en en en en en en en en en en en en nl en en fr en en en en en en en en en en en en nl en en en en en en en en en fr en da en en en en en en en nl en en en en en fr en en en en en en en en nl vi en en en en en en fr en da en en en en en en en nl en en en en en en en en en en en en en en en en en en nl fr en en en fr en en en en en en en en nl en en en en en en en en en en en en nl en en en en en en en fr en da en en en en en en en nl en en en en en en en fr en en en en en en en en nl en en en en en en fr en da en en en en en en en nl en en en en en en en en en en nl en en en en en en en en fr en da en en en en en en en nl en en en en en en en en en en nl en en en en en en en fr en da en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in Third-Party Forums only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
SQLTools: stopping and restarting SQLTools
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
Normally I init my database with SqlTools when I start my prog and shut it down when I'm done using sql_shutdown.
This time, I want to shut everything down and later in the same program, restart it.
Do I have to Authorize and Init SQL tools again or only re-connect to my database? I can't get either way to work as of now...
Once you've done SQL_Shutdown, i don't think you'll be able to reconnect. I suspect that the SQL_Authorize would stick; you'd just need to do SQL_Initialize again.
Real programmers use a magnetized needle and a steady hand
here's how I'm doing it but it's not working on the re-open
Function openDatabase() As String Local connectionString As String If initDB=0 Then ' authorize sql tools once only SQL_Authorize &MyCode initDB=-1 ' global var- flag if already authorized End If SQL_Initialize 2,2,50,3,3,0,0,0 connectionString="Driver={Microsoft Access Driver (*.mdb)};Dbq="+programDir+"\data\inspector.mdb;Uid=Admin;Pwd= ;" sql_openDatabase(%inspectorDB,connectionString,%PROMPT_TYPE_NOPROMPT) FUNCTION = SQL_ErrorQuickAll End Function
Join Date: Oct 1987
24 Feb 2009, 04:41 AM
Sorry, but SQL Tools will not allow you to use SQL_Initialize more than once, so SQL_Shutdown is "permanent". From the SQL_Initialize docs:
If an attempt is made to re-initialize SQL Tools after it has been successfully initialized, ERROR_CAN'T_BE_DONE will be returned.
So once your program calls SQL_Shutdown, you're done using SQL Tools functions. Why do you want to? Maybe I can suggest an alternative.
-- Eric Pearson, Perfect Sync, Inc.
"Not my circus, not my monkeys."
Join Date: Aug 1998
24 Feb 2009, 08:02 AM
> From the SQL_Initialize docs: If an attempt is made to re-initialize SQL Tools ....
What if you load the library dynamically, initialize, use, shutdown, freelibrary, and start over?
Not that this is a good idea or a bad idea. Seems to me intitializing a library at start and shutting it down at the end makes perfect sense.
What is IMO a bad idea is maintaining an open connection to a database, but I know SQL Tools lets you connect and disconnect at will.
Port Washington WI USA
Join Date: Oct 1987
24 Feb 2009, 08:51 AM
> What if you load the library dynamically, initialize,
> use, shutdown, freelibrary, and start over?
Sure, I suppose that would work. But using the GetProcAddress API to find each function, using CALL DWORD for every call to a SQL Tools function... seems like a lot of extra work for no real gain (as far as I know).
"Not my circus, not my monkeys."
Join Date: Aug 1998
24 Feb 2009, 09:12 AM
I was guessing that "Initialize" creates some GLOBAL or STATIC or THREADED control structures which are cleaned up (deallocated) on DLL_PROCESS_DETACH.
I guess I made a good guess.
Port Washington WI USA
Join Date: Nov 1999
24 Feb 2009, 10:11 AM
Here's what I'm doing:
I have a local app on a roaming field laptop that keeps a database.
Occasionally, that local computer will sync up it's data with an online SQL server.
My original plan opens the local db for the user's everyday work.
Then, when they want to sync, it opens the remote db and syncs up the data. I wanted then to close the remote db when I was done.
Anyway, I think my work around will be to open (by open I mean authorized and init and in sqltools) the remote db when they want to sync and it will just stay open until the program is closed and sql_shutdown is ran.
Otherwise, if they try to sync again, I'll have to test for connectivity before I can write to the db again (which I need to do anyway). I'll use a flag to decide if the remote db has already been init'd and only do it once.
Last edited by Shawn Anderson; 24 Feb 2009, 10:13 AM. Reason: clarification
Join Date: Oct 1987
24 Feb 2009, 10:20 AM
To be clear, SQL_Authorize and SQL_Initialize do not make actual database connections. We use SQL_OpenDatabase for that, and you can use SQL_CloseDatabase as well. You can open and close database connections at will, as many times as you like. It's just the Auth/Init/Shutdown functions that can't be used repeatedly.
If you close a database connection with SQL_CloseDatabase (or SQL_CloseDB) then there is virtually no penalty for keeping SQL Tools active in a program. Other than a little memory, of course. No reason to call SQL_Shutdown until you are truly done.
"Not my circus, not my monkeys."
Join Date: Nov 1999
24 Feb 2009, 10:50 AM
Yes, sorry my terminology is too loose.
OK, so I think the way to go is to go ahead and init the database whenever but to open it when I need to write to it and close it when I'm done.
That way I can troubleshoot if I have connectivity (ie: internet connection available) by whether or not the db opens. That is a better solution to what I was going to do (ping or similar).
Join Date: Aug 1998
24 Feb 2009, 01:25 PM
>my terminology is too loose...
Say it ain't so, Joe!
Port Washington WI USA
Join Date: Oct 1987
24 Feb 2009, 01:35 PM
Shawn, that sounds like a good plan.
Actually, that can cause trouble with the ODBC subsystem, hence the need for an explicit call to a Shutdown function before the DLL is unloaded.
But overall you're right, SQL_Initialize sets up a bunch of arrays and other control structures, which are then destroyed by SQL_Shutdown. There are currently no provisions for re-dimming the arrays (etc.) because it's not necessary when the system is used as designed.
"Not my circus, not my monkeys."
Join Date: Aug 1998
24 Feb 2009, 03:16 PM
>because it's not necessary when the system is used as designed.
I wonder how much code has been written over the years to support users who wanted software to work "NOT as designed?"
Port Washington WI USA
Join Date: Nov 1999
26 Feb 2009, 06:09 AM
well at least I didn't use my normal technical terms of "thing-a-ma-jigger" or "wutch-ya-ma-call-it".
Join Date: Aug 1998
26 Feb 2009, 07:46 AM
>my normal technical terms of "thing-a-ma-jigger" or "wutch-ya-ma-call-it
Those I might excuse, since it would be obvious you are at least trying to recall the correct teminology.
What I have a problem with is "This code crashes." I would like to think anyone who is permitted to compile programs and execute them would know the difference between "won't compile," "does not execute to completion" and "produces incorrect output."
Port Washington WI USA
Join Date: Nov 1999
26 Feb 2009, 10:02 AM
I will note that in my do-ma-flach-ee
Join Date: Aug 1998
26 Feb 2009, 10:22 AM
For our friends in West Virginia:
"thingamajig", "watchamacallit" and all these other terms are synonyms for "thang."
If you'll just tell your cousins that ought to cover everyone in your state.
Port Washington WI USA
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 04:10 AM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.