0

Hi I have been editing my script with some forum help. I just need to add one last section. I need to indicate to the user running the .BAT file if the row was inserted or not? can anyone help me polish this off and I can go home a happy man !

@echo off

SET /P "NeedsList= Do you want to display a casino list? (press l for list or any other key)"

IF /I NOT [%NeedsList%] == [L] GOTO :cont
osql -STEMP7 -E -dAAMS888 -w256 -Q "SET NOCOUNT ON SELECT casino_desc from casino" -b 

:cont
set /p var1= Enter Casino Name : 
set /p var2= Enter Screen name : 

osql -STEMP7 -E -dAAMS888 -w256 -Q "DECLARE @r int EXEC @r = usp_AddToObservationtbl  '%var1%','%var2%' SELECT @r" -b -oc:\bat\observation.log
exit %errorlevel%

**need code here to indicate if they have entered a valid casino name**
woliveirajr
  • 9,433
  • 1
  • 39
  • 49
Chris Wood
  • 535
  • 9
  • 28

1 Answers1

0

I don't know about osql, but if that command can return an ERRORLEVEL code (In C language for example is the Exit code), you can trap it and make an If-statement to Echo your message.

Like This:

IF %ERRORLEVEL% == 0 (
    Echo The row was sucessfull inserted
) ELSE (
    Echo Ups, It wasn't my faul!
)
Andriy M
  • 76,112
  • 17
  • 94
  • 154
Santiago
  • 2,190
  • 10
  • 30
  • 59
  • 1
    @Chris Wood: Note that you need to add the code of this kind either *before* or *instead of* `exit %errorlevel%`, because `exit` terminates executing of the script. – Andriy M Jul 13 '11 at 16:32