` Comment on an Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Add a comment to an Icetips Article

Please add your comments to this article. Please note that you must provide both a name and a valid email address in order for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!

Your Name:  
Email:  
Header text/Subject:  

Please enter your comment in the box below:

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

SQL Related Articles: Starting SQL Anywhere server engine
2007-08-28 -- Arnor Baldvinsson
 
>Do you have a simple example of "attempt to run"?

Ok, here it is. Note that this uses our Icetips Utilities classes to find the window etc.

In the procedure where I set up filenames, etc. I attempt to open one file. If it fails, I call this procedure:

 Open(HighLevelFile)
 If ErrorCode()
   FEC = FileErrorCode()
   ITU.ODS('Error: ' & ITU.ErrorMsg(True,True))
   Loc:Level = LEVEL:FATAL
   If FEC = 08001
     If Loc:StartServer
       Loc:Level = StartSQLServer()
     End
   Else
     Do ShowMessage
   End
 Else
   Loc:Level = LEVEL:Benign
   Close(HighLevelFile)
 End
 Return(Loc:Level)
The StartSQLServer() is what does the job. It's a standard window procedure that posts an event at the end of OpenWindow handler. When I get that event in TakeEvent I call a routine:
StartStartingAttempts           ROUTINE
 Data
DBPath  CString(256)
ServerParamFile CString(1025)
RCode  Long
CLine  CString(2049)
 Code
 Loc:Level = LEVEL:Fatal
 DBPath = GetReg(REG_LOCAL_MACHINE,|
          'SOFTWARE\ClientName\Database','Location')
 DBPath = ITU.GetFilePart(DBPath,FNS_Drive+FNS_Path)
 ServerParamFile = DBPath  & '\serverparameters.pm'
 CLine = '"dbsrv9.exe" "@' & Clip(ServerParamFile) & '"'
 SetCursor(CURSOR:Wait)
 Run(CLine)
 0{Prop:Timer} = 50
 Loc:Counter = 0
And in the timer event handler I do this:
If EVENT() = EVENT:Timer
  If ITU.FindWindow('Adaptive Server Anywhere')
    0{Prop:Timer} = 0
    0{Prop:Hide}  = True
    SetCursor()
    Message('It appears that the SQL server is now up and running.','Server running',ICON:Exclamation)
    Loc:Level = LEVEL:Benign
    Post(EVENT:CloseWindow)
  End
  Loc:Counter += 1
  If Loc:Counter > 10
    0{Prop:Timer} = 0
    SetCursor()
    Message('It appears that the server can not be started automatically.  Please attempt to manually '
&|
            'start it by using the start menu in windows.  If the server can not be started manually, '
&|
            'please contact the database administrator or developer.','Server did not start',ICON:Hand)
    Loc:Level = LEVEL:Fatal
    Post(EVENT:CloseWindow)
  End
End
Because of the Message() in there I have never hit it fast enough so that the server engine isn't completely up and running, but if you wanted to automate this completely and show no message when it starts, then you'd probably have to put in a few second delay to make sure that the engine is connected and everything's ready.

Best regards, ArnĂ³r Baldvinsson Icetips Creative, Inc. San Antonio, Texas, USA



Today is November 23, 2024, 2:23 am
This article has been viewed 35237 times.
Google search has resulted in 5 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: