|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Saturday, June 16, 2012 1:16 AM
Points: 14,
Visits: 73
|
|
Hello,
I'm write installation package using inno for ms sql script. I have the following code:
strParam := '-U hel -P password -S ServerName -d test -Q "sp_test"'; try Exec('sqlcmd.exe', strParam, '', SW_SHOW, ewWaitUntilTerminated, ResultCode); result := ResultCode = 0; except Exec('osql.exe', strParam, '', SW_SHOW, ewWaitUntilTerminated, ResultCode); result := ResultCode = 0; end;
Sp executes ok but black screen with sqlcmd.exe is hanging until either I type exit or close it. I want a window with sqlcmd.exe closed after sp is executed.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 7:09 AM
Points: 6,701,
Visits: 11,730
|
|
WaitingWonder2 (10/18/2011)
Hello, I'm write installation package using inno for ms sql script. I have the following code: strParam := '-U hel -P password -S ServerName -d test -Q "sp_test"'; try Exec('sqlcmd.exe', strParam, '', SW_SHOW, ewWaitUntilTerminated, ResultCode); result := ResultCode = 0; except Exec('osql.exe', strParam, '', SW_SHOW, ewWaitUntilTerminated, ResultCode); result := ResultCode = 0; end;
Sp executes ok but black screen with sqlcmd.exe is hanging until either I type exit or close it. I want a window with sqlcmd.exe closed after sp is executed.
You can do this by invoking the cmd shell using the /C switch. You may need to rework your code to allow for the change in cmomand line structure however.
Try running this from the Run prompt and you'll see what I mean:
cmd /C "sqlcmd.exe /? > C:1.txt"
As a side note...you have a potential latent bug in your code. It's not a good idea to use exceptions as a control flow mechanism. If you call to sqlcmd.exe does some work in the database but still exits with an error you could potentially run some database commands a second time with the call using osql in your except block. I would recommend employing a different approach to determining when to osql versus sqlcmd.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|