Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record locking a VFP table from C#.NET 1

Status
Not open for further replies.

dgrewe

MIS
Dec 1, 1999
1,285
0
0
US
I know this is more of a C#.NET question, but I'm a VFP programmer just learning C# and can not find the answer to this question anywhere.

In C#.NET I have to access a VFP table (SYSKEY.DBF) in a VFP database using 2 fields (dbfname c(10), keyfield c(10)). The table has No Primary Index or No Candidate index but dbfname+keyfield is unique. Both fields have an index on them. "SELECT LASTKEY FROM SYSKEY WHERE UPPER(ALLTRIM(DBFNAME))="OWMAIN" AND UPPER(ALLTRIM(KEYFIELD))="OWMAINID"

I have to
Open the database
Use the table
Find that unique record
lock the record
go into a loop into utill unlocked
Get the value of field lastkey (int)
Incriment it by one,
Replace the value in the field
save record
close table.
close connection.

Since several VFP application access this table at the same time I can not open it exclusive.

All the sample C# code I find for opening a VFP table by ODBC/OLEDB pulls the data into a cursor and plays with it then replaces the data. My supervisor does not want me to do it that way.

I have wrote a classes in C# one that uses the Cursor method but allows another user to get the same record. From what I have read I can not use a DataReader/DataAdapter because there is no Primary key field/index on the table.

I downloaded the VFPToolkitNET and they access the VFP tables with cursors, so I can not use it.

Anyone have any ideas ???


David W. Grewe Dave
 
You don't need to do anything complex. Just code it in a Stored procedure and call stored procedure from .Net using OleDbCommand.

Cetin Basoz
MS Foxpro MVP, MCP
 
If your VFP data in a database container?

If that is the case what Cetin has said will work fine.


If your data in not in a DBC you'll have to get creative. I have an idea that migth work if this is the case and I'll try to write it up if thats what you need.

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top