Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using SQLCONNECT
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00851873
Message ID:
00852674
Vues:
8
Hi Chris...
>1. Is this all OK? Is there anything I am missing?
It seems Ok, I'll add AERROR() function when SPT functions returns a
negative value

>2. Is it customary to open just one connection to the database when the >application is started and then close it when when the app is closed?
Yes, it is fine, but It could be better use a conection & closed after, keeping it open consume Server resources, but if you are using VFP Data then there's no big deal about it.

>3. Lastly - I am used to using transactions in Visual FoxPro databases with ROLLBACK etc. Can someone provide (or point to) an example of how this is done? Is it a case of multiple SQLEXEC commands wrapped in some procedure or is it all done in one stored procedure?
Use Manual transactions...
SQLSETPROP(yourConnection,"Transactions",2)
SQLCOMMIT(yourConnection)
SQLROLLBACK(yourConnection)
The SPT Functions are great!, try to encapsule into a Class, I have my own class, it works cool, I have a sample proyect using the basic functions, it is in spanish, but you can easy understand it...

http://www.portalfox.com/modules.php?op=modload&name=Downloads&file=index&req=getit&lid=110

Have fun!



>Thank you all for the responses! There were great links to helpful articles especially those on the Wikis site.

>I am creating my stored procedures in SQL Server 2000 - so I am just needing to connect, execute the stored procedures and return the resulting data into a cursor so I can work with it. I wanted to do this without having to create a DSN on every client.

>After reading the information and your posts I managed to connect to SQL and execute a stored procedure on northwind using this:
>PUBLIC gnConnHandle
>LOCAL llConnected, lcCommand
>STORE -1 TO gnConnHandle
>STORE .F. TO llConnected
>STORE "" TO lcCommand
>STORE SQLSTRINGCONNECT("DRIVER=SQL >Server;SERVER=PREXP01;UID=sa;PWD=mypass;"+;
     "APP=Microsoft® Visual FoxPro®;WSID=PREXP01;DATABASE=Northwind") ;
    TO gnConnHandle
>IF gnConnHandle < 0
>   =MESSAGEBOX('Cannot make connection', 16, 'SQL Connect Error')
>ELSE
>   =MESSAGEBOX('Connection made', 48, 'SQL Connect Message')
>   llConnected = .T.
>ENDIF
>lcCommand = "exec CustOrderHist ALFKI"
>=SQLEXEC(gnConnHandle, lcCommand, "curTemp")
>SELECT curTemp
>BROWSE
>USE IN curTemp
>IF llConnected THEN
>	=SQLDISCONNECT(gnConnHandle)
>ENDIF
>It works...

>1. Is this all OK? Is there anything I am missing?
>2. Is it customary to open just one connection to the database when the >application is started and then close it when when the app is closed?
>3. Lastly - I am used to using transactions in Visual FoxPro databases with ROLLBACK etc. Can someone provide (or point to) an example of how this is done? Is it a case of multiple SQLEXEC commands wrapped in some procedure or is it all done in one stored procedure?
Apoya a Visual FoxPro usandolo legalmente
--
¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º
Espartaco Palma Martínez
SysOp PortalFox
http://www.portalfox.com
esparta@portalfox.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform