Article ID: 177056
Article Last Modified on 3/19/2005
********Start of Setup.prg***********
MyConnStr="'driver=sql server;server=myserver;uid=UserName;pwd=StrongPassword; "+ ;
"database=Pubs'"
*String to create the SQL Server Stored Procedure in Pubs
SP_String="Create Proc KBtemp @Param1 char(20)OUTPUT " + ;
"as Select @Param1='Return Success'"
CREATE DATABASE SP_Test
CREATE CONNECTION SP_Test CONNSTRING &MyConnStr
MyConn=SQLCONNECT('SP_Test')
IF MyConn > 0 then
rSucc1=SQLEXEC(MyConn, SP_String)
IF rSucc1 == -1 then
MESSAGEBOX("Creating Stored Procedure Failed")
AERROR(MyError)
?"Create Stored Proc Error: "
DISPLAY MEMORY LIKE MyError
ENDIF
SQLDISCONNECT(MyConn)
ELSE
MESSAGEBOX("SQL Connection Failed")
ENDIF
*******End of Setup.prg*************
Note Replace the server, user ID and password in MyConnStr with the
appropriate server name, user ID, and password on your system.
*******Start of CallSP.prg************
*Variable for the return parameter
Z=SPACE(25)
SP_Call="{Call KBTemp (?@Z)}"
MyConn=SQLCONNECT('SP_Test')
IF MyConn > 0 then
rSucc1=SQLEXEC(MyConn,SP_Call)
IF rSucc1<>-1 then
MESSAGEBOX(Z)
ELSE
MESSAGEBOX("Calling Stored Procedure Failed")
AERROR(MyError)
?"Calling Stored Proc Error: "
DISPLAY MEMORY LIKE MyError
ENDIF
SQLDISCONNECT(MyConn)
ELSE
MESSAGEBOX("SQL Connection Failed")
ENDIF
******End of CallSP.prg*************
Additional query words: variable SQl odbc
Keywords: kbprb KB177056