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
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