当前位置: 动力学知识库 > 问答 > 编程问答 >

database - Editing / updating Excel table with Delphi AdoTable / Grid

问题描述:

I am trying to read-write from-to an Excel 2000 file in XE5-Delphi with a TADOTable and Grid component. Reading is working but when try to change some fields receive this:

"insufficient key column information for updating or refreshing"

Try to change cursor type, locking type, anything I found in the forums, did not work. Most of the recommendations are to define an index key, but this is Excel, so all are useless.

My code is:

Begin

MastTable.FormMast.ADOTableMast.DisableControls;

MastTable.FormMast.ADOTableMast.Edit;

for i := 0 to SrcList.Items.Count-1 do

begin

MastTable.FormMast.ADOTableMast.First;

while not MastTable.FormMast.ADOTableMast.EOF do

begin;

MastTable.FormMast.ADOTableMast.Edit;

if MastTable.FormMast.ADOTableMast.FieldByName('FieldNames').Value = SrcList.Items[i] then

MastTable.FormMast.ADOTableMast.FieldByName('FieldNames').Value:='Yes'

else

MastTable.FormMast.ADOTableMast.FieldByName('FieldNames').Value:='';

MastTable.FormMast.ADOTableMast.Post;

MastTable.FormMast.ADOTableMast.Next;

end;

end;

MastTable.FormMast.ADOTableMast.Refresh;

MastTable.FormMast.ADOTableMast.EnableControls;

End;

My connection string is:

Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=N:\DP-DATA\Lee_County\LCPA\DistPropLCPA_Filters.xls;Mode=ReadWrite;Persist Security Info=False;Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False;Jet OLEDB:Bypass UserInfo Validation=False;

Using Windows Vista Ultimate 64bit, Microsoft Database Engine 32bit installed.

Could anybody help me?


After three days and 66 visitors, it seems this is a difficult question. Frankly, I am very surprised that nobody could (wants?) help me. I feel forced myself to simplify the question: COULD ANYBODY SHOW ME AN EXAMPLE CODE IN XE5-DELPHI WHICH COULD READ AND WRITE EXCEL-2000 FILES? NOT GUESSES, OPINIONS, IDEAS, ADVICES! A FULLY FUNCTIONAL PROGRAM WITH COMPILED VERSIONS RUNNING ON XP, VISTA, WIN7 32/64 BIT MACHINES?! IS THIS REALLY SO DIFFICULT IN XE5-DELPHI????

分享给朋友:
您可能感兴趣的文章:
随机阅读: