开发者

C# DBF File default ordering

I need to write records to a DBF file in C# (which is working fine) but the requirement is that when the user opens the resulting dbf file, the records are sor开发者_StackOverflow中文版ted according the values in one of the columns. I have accomplished this with other formats by simply setting the column as the primary key. However, I am unable to create a primary key, as I get the the error ("not supported for non-dbc"). Is there any other way I can achieve the "sorting"?


Data being stored in a DBF or any other database is NOT ever stored sequentially but utilize indexes and ORDER BY clauses when retrieving data. So, I would just worry about your query when RETRIEVING the data to include as such...

select * from whateverTable order by Column1, Column8, Column20
(or whatever columns are of concern)

Then, it doesn't matter WHAT order they are actually entered....


For free DBF files, you will need to write the records in the order you wish for them to appear.

Note: I know your comment above says you are doing this, but this is the answer. If you don't tell us and/or show us how you are writing out to the table, we can't help any further.


Tables that aren't in a database ("free tables" in foxpro nomenclature) support Candidate indexes:

Similar to a primary index, a candidate index contains an index key for each record in a table and prohibits duplicate values in the fields or index expression specified for generating index keys.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜