Article ID: 198606
Article Last Modified on 4/15/2005
sp_configure "user options", 512 SET NOCOUNT ON
gnConnHandle=SQLSTRINGCONN('DRIVER={SQL Server};' + ;
'SERVER=SPHINXSQL;DATABASE=ALMIS;UID=UserName;PWD=StrongPassword')
sqlcommand="USE ALMIS"
=SQLEXEC(gnConnHandle,sqlcommand)
testval=0
sqlcommand="sp_configure 'user options'"
testval=SQLEXEC(gnConnHandle,sqlcommand,'mytest')
oldvalue=0
IF testval>0
SELECT mytest
oldvalue=config_value
BROW
ENDIF
IF oldvalue<>512
* Insert code here that would allow the user to view and modify data
* contained in an updateable cursor.
ELSE
* Insert code here that would allow the user to view but not modify
* data in a cursor.
ENDIF
=SQLDISCONNECT(gnConnHandle)
sp_configure "user options", 512EXECuting the following SQL Server commmand also turns off the message, returned at the end of each statement, indicating the number of rows affected by the statement. SET NOCOUNT ON also prevents SQL Server from sending DONE_IN_PROC messages to the client for each statement executed in a stored procedure:
SET NOCOUNT ON
PUBLIC ox
ox=CREATEOBJECT('test1')
ox.SHOW
DEFINE CLASS test1 AS FORM
TOP = 15
LEFT = 37
HEIGHT = 250
WIDTH = 360
DOCREATE = .T.
CAPTION = "Form1"
NAME = "Form1"
ADD OBJECT command1 AS COMMANDBUTTON WITH ;
TOP = 216, ;
LEFT = 120, ;
HEIGHT = 25, ;
WIDTH = 120, ;
CAPTION = "\<Delete Record", ;
NAME = "Command1"
ADD OBJECT grid1 AS GRID WITH ;
HEIGHT = 145, ;
LEFT = 24, ;
TOP = 24, ;
WIDTH = 312, ;
NAME = "Grid1"
PROCEDURE LOAD
PUBLIC gnConnHandle, testval, old_user_option
gnConnHandle=SQLSTRINGCONN('DRIVER={SQL Server};' + ;
'SERVER=SPHINXSQL;DATABASE=PUBS;UID=UserName;PWD=StrongPassword')
*!*
*!* You may have to change the SERVER and DATABASE
*!* Values. Make sure user specific UID and PWD
*!* values are specified.
*!*
SQLCommand="USE PUBS"
*!*
*!* If using a different Database Substitute PUBS
*!* for the name of the Database to be used.
*!*
=SQLEXEC(gnConnHandle,SQLCommand)
testval=0
*!* Retrieve current global user options settings.
SQLCommand="sp_configure 'user options'"
testval=SQLEXEC(gnConnHandle,SQLCommand,'mytest')
old_user_option=0
IF testval>0
SELECT mytest
old_user_option=config_value
ENDIF
*!* Comment the lines indicated below and the updates succeed,
*!* unless the global SQL Server user options configuration
*!* is 512 and SET NOCOUNT ON has been issued
*!*
*!* TOP OF LINES TO COMMENT
SQLCommand="sp_configure 'user options',512"
testval=SQLEXEC(gnConnHandle,SQLCommand)
SQLCommand="reconfigure"
=SQLEXEC(gnConnHandle,SQLCommand)
SQLCommand="set nocount on"
testval=SQLEXEC(gnConnHandle,SQLCommand)
*!* END OF LINES TO COMMENT
*!*
*!* Create a table for testing in the Pubs database.
SQLCommand="CREATE TABLE TESTING (STORE_ID CHAR(5) NOT NULL," +;
" STOR_NAME CHAR(35) NOT NULL)"
testval=SQLEXEC(gnConnHandle,SQLCommand)
*!* Insert three records into the test table
FOR i=1 to 3
SQLCommand="INSERT INTO TESTING VALUES ('" + REPLICATE("0",4) +;
ALLTRIM(STR(i)) + "','Store Number " + ALLTRIM(STR(i)) + "')"
testval=SQLEXEC(gnConnHandle,SQLCommand)
NEXT
SQLCommand="SELECT * FROM TESTING"
testval4=SQLEXEC(gnConnHandle,SQLCommand)
SELECT sqlresult
=AFIELDS(testresult)
szKeyList=testresult[1,1]
szFieldList=""
szUpdateList=""
*!* Store the field names to a comma delimited list.
FOR i=1 TO ALEN(testresult,1)
IF LEN(ALLTRIM(szFieldList))>0
szFieldList=ALLTRIM(szFieldList)+","
ENDIF
szFieldList=szFieldList+ALLTRIM(testresult[i,1]) + ;
" DBO.TESTING."+ALLTRIM(testresult[i,1])
IF LEN(ALLTRIM(szUpdateList))>0
szUpdateList=ALLTRIM(szUpdateList)+","
ENDIF
szUpdateList=szUpdateList+ALLTRIM(testresult[i,1])
NEXT
*!* Set the cursor so that it is updatable
=CURSORSETPROP("Tables", 'DBO.TESTING')
=CURSORSETPROP("UpdateNameList",szFieldList)
=CURSORSETPROP("KeyFieldList",szKeyList)
=CURSORSETPROP("UpdatableFieldList", szUpdateList)
=CURSORSETPROP("WhereType",1)
=CURSORSETPROP("SendUpdates", .T.)
ENDPROC
PROCEDURE UNLOAD
=TABLEREVERT(.T.)
*!* Drop the test table that was created from the Pubs Database.
SQLCommand="DROP TABLE TESTING"
=SQLEXEC(gnConnHandle,SQLCommand)
*!* Reset SQL Server Global user option configuration settings
*!* to original values.
SQLCommand="sp_configure 'user options'," + ;
ALLTRIM(STR(old_user_option))
=SQLEXEC(gnConnHandle,SQLCommand)
SQLCommand="reconfigure"
=SQLEXEC(gnConnHandle,SQLCommand)
SQLCommand="set nocount off"
=SQLEXEC(gnConnHandle,SQLCommand)
=SQLDISCONN(gnConnHandle)
ENDPROC
PROCEDURE command1.CLICK
DELETE
SKIP
THISFORM.REFRESH
ENDPROC
ENDDEFINE
DO SQLDEMO
Additional query words: kbDSupport kbDSE
Keywords: kbdatabase kbprb kbclientserver kbpending KB198606