Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date and time from server
Message
From
02/05/2003 08:27:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
02/05/2003 07:54:49
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00784019
Message ID:
00784047
Views:
13
This message has been marked as the solution to the initial question of the thread.
>ok, this is what I do:
>
>...
>SELECT 0
>cxCustomer = SYS(3)
>CREATE CURSOR cxCustomer (
> CustAlias C(15),;
> NmCust C(40),;
> Contact C(40),;
> Address M(4)))
>...
>**************
>
>...
>lnSQLExecSuccess = SQLPREPARE(lnSQLConnHandle, "SELECT * from CUSTOMER order by CustAlias", "RESULTS")
>lnSQLConnHandle = SQLSTRINGCONNECT(lcSQLConnStr)
>IF lnSQLConnHandle < 1
> LOCAL laErrArray[1]
> AERROR(laErrArray)
> WAIT WINDOW "Unable to connect:" + CHR(13) + laErrArray[1,2]
> RETURN .F.
>ENDIF
>
>lnSQLExecSuccess = SQLPREPARE(lnSQLConnHandle, "SELECT * from CUSTOMER order by CustAlias", "RESULTS")
>lnSQLExecSuccess = SQLEXEC(lnSQLConnHandle)
>
>IF lnSQLExecSuccess <> 1
> LOCAL laError[1]
> AERROR(laError)
> WAIT WINDOW "SQLEXEC() Failed:" + CHR(13) + laError[1,2]
>ENDIF
>.....
>
>******
>
>SELECT cxCustomer
>ZAP
>
>SELECT RESULTS
>FOR I = 1 TO RECCOUNT()
> SELECT RESULTS
> GO I
>
> SCATTER MEMVAR
> SCATTER MEMVAR MEMO
> INSERT INTO cxCustomer FROM MEMVAR
>ENDFOR
>
>SELECT cxCustomer
>GO TOP
>
>THISFORM.grdCustomer.REFRESH()
>**********
>
>The error:
>No update tables are specified. Use the Tables property of the cursor.
>
>Hope this could explain my question :) Or may be there is another way?
>
>Best regards,
>William

William,
Code is somewhat obscure. I'll try to my best :)
SELECT 0
cxCustomer = SYS(3)
CREATE CURSOR cxCustomer  (
                       CustAlias       C(15),;
	 	       NmCust          C(40),;
	 	       Contact         C(40),;
	 	       Address         M(4)))

* Why cxCustomer = sys(3) ? Maybe used as a variable elsewhere.
* Why do you ever need to create this and put SQL results in it ?
* Assuming you've a good reason to do so

* Above code is almost equivalant to (except sys(3))
CREATE CURSOR cxCustomer  ( ;
                       CustAlias       C(15),;
	 	       NmCust          C(40),;
	 	       Contact         C(40),;
	 	       Address         M)
* Nothing important here - just preference
I didn't understand why multiple SQLExec to same table, but probably changing connection in between. Since you're doing it once you could drop the SQLPrepare (unused lnSQLExecSuccess as well):
lnSQLExecSuccess = SQLPREPARE(lnSQLConnHandle, ;
 "SELECT * from CUSTOMER order by CustAlias", "RESULTS")
lnSQLConnHandle = SQLSTRINGCONNECT(lcSQLConnStr)
IF lnSQLConnHandle < 1
    LOCAL laErrArray[1]
    AERROR(laErrArray)
    WAIT WINDOW "Unable to connect:" + CHR(13) + laErrArray[1,2]
    RETURN .F.
ENDIF

lnSQLExecSuccess = SQLPREPARE(lnSQLConnHandle, ;
 "SELECT * from CUSTOMER order by CustAlias", "RESULTS")
lnSQLExecSuccess = SQLEXEC(lnSQLConnHandle)

IF lnSQLExecSuccess <> 1
	LOCAL laError[1]
    AERROR(laError)
    WAIT WINDOW "SQLEXEC() Failed:" + CHR(13) +  laError[1,2]
ENDIF
Could be replaced by :
lnSQLConnHandle = Sqlstringconnect(lcSQLConnStr)
If lnSQLConnHandle < 0
  Local laErrArray[1]
  Aerror(laErrArray)
  Wait Window "Unable to connect:" + Chr(13) + laErrArray[1,2]
  Return .F.
Endif

If ( SQLEXEC(lnSQLConnHandle, ;
	"SELECT * from CUSTOMER order by CustAlias", "RESULTS") ) < 0
  Local laError[1]
  Aerror(laError)
  Wait Window "SQLEXEC() Failed:" + Chr(13) + laError[1,2]
EndIf
And finally (if cxCustomer ever needed) :
select customer
zap
...
thisform...
Could be replaced by :
SELECT cxCustomer
Zap && Needed ?
Append From RESULTS
THISFORM.grdCustomer.REFRESH()
If you need a structure like you did (for i=1 to reccount()..endfor block)then do it like this :
Select RESULTS
scan
  Scatter Memvar Memo
  Insert Into cxCustomer From Memvar
Endscan
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform