Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query VFP cursor and SQL server table
Message
From
27/02/2004 12:34:47
Suhas Hegde
Dental Surgeon
Sirsi, India
 
 
To
27/02/2004 11:14:28
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00881433
Message ID:
00881557
Views:
15
>Hi,
>if my customer table is DBF file
>will
>sqlexec(han,"select cus_id into #temp from customer where 1 = 0")
>works?


let me still more clear.
I have modified it to be more readable.

Orders - here is a SQL SERVER table.
Customer - here is a local vfp cursor or vfp table (dbf) having cus_id
sqlexec(han,"select cus_id into #temp from orders where 1 = 0") && would create a temp table on the server which would be droped when the connection closes or u drop it.
** Now populate this table
sqlexec(han,"select * from #temp","temp")
** set buffering to table
cursorsetprop("buffering",5,"temp")
** now populate the temp table created on the sqlserver with the cus_id which u have.
select Customer && i think it is already open and contans the cus_id
scan
 insert into temp values(customer.cus_id)
endscan
*******make this updatable
cursorsetprop("tables","#temp","temp")
cursorsetprop("UpdateNameList","cus_id #temp.cus_id","temp")
cursorsetprop("UpdatableFieldList","cus_id","temp")
cursorsetprop("KeyFieldlist","cus_id","temp")
cursorsetprop("Sendupdates",.t.,"temp")
tableupdate(2,.t.,"temp")
** use inner join to retrive the recordset
sqlexec(han,"select orders.* from orders inner join "+;
             "#temp on orders.cus_id = #temp.cus_id","MYordercursor")
sqlexec(han,"drop #temp") && drop the table
Now the Myordercursor contains the required results.

Another way showed to me by Cetin Basoz was to use the openrowset function of the sqlserver to connect to the local vfp table. Although i have used the eailier but not this u will have to check this out yourself.
SQLExec(lnHandle, ;
 "select * from orders as rmtR"+;
 "   inner join OPENROWSET('VFPOLEDB.1', "+;
 "   '"+Sys(5)+Curdir()+"';'';'',"+;
 "   'select cus_id from customers') as locR"+;
 "  on rmtR.cus_id = locR.cus_id",'Myordercursor' )
Previous
Reply
Map
View

Click here to load this message in the networking platform