Home > Back-end >  About the Excel data problems in bulk import to Access!!!!!!
About the Excel data problems in bulk import to Access!!!!!!

Time:09-18

Procedure TFm_Main. Button6Click (Sender: TObject);
Var
SSql xlspath, mdbpath: string;
The begin
If OpenDialog1. Execute then
Xlspath:=OpenDialog1. FileName;//Excel path
Mdbpath:=extractfilepath (application. Exename) + 'Data. The MDB';
If the trim (xlspath)='then
exit;
Fm_SWDJ. ADOC. Connected:=False;
Try
Fm_SWDJ. ADOC. The ConnectionString:=
'the Provider=Microsoft. Jet. The OLEDB. 4.0. Data Source='+
Mdbpath + '; Persist Security Info=False ';
Fm_SWDJ. ADOC. Connected:=true;
Try
///
Adoquery1. Close;//////////////////////////////////////
Adoquery1. SQL. The Clear;//import data before
SSql:='Delete * From the addressee information list;//first empty database
Adoquery1. The Parameters. The Clear;//
Adoquery1. ParamCheck:=false;//
Adoquery1. SQL. Text:=sSql;//////////////////////////////////////
Adoquery1. Execsql;//////////////////////////////////////
///
Adoquery1. Close;//
Adoquery1. SQL. The Clear;//////////////////////////////////////
SSql:=
'INSERT INTO the addressee information list (document number, title, document number, system unit, the registration date, file type, entity type, number of pages, copies, notes)' +
'SELECT' +
'document number, title, document number, system unit, the registration date, file type, entity type, number of pages, copies, notes' +
'the FROM [excel 8.0; the database=' + xlspath +]. [Sheet1 $] '.
Adoquery1. The Parameters. The Clear;
Adoquery1. ParamCheck:=false;
Adoquery1. SQL. Text:=sSql;
adoquery1. Execsql;
MessageBox (GetActiveWindow (), 'bulk import EXCEL success! ', 'congratulations', MB_OK +
MB_ICONWARNING);
Fm_SWDJ. ADOD. Active:=False;
Fm_SWDJ. ADOD. Active:=True;
Except,
MessageBox (GetActiveWindow (), 'bulk import EXCEL failed! ', 'warning', MB_OK +
MB_ICONWARNING);
end;
Except,
MessageBox (GetActiveWindow (), 'connection ACCESS failed! ', 'warning', MB_OK +
MB_ICONWARNING);
end;
end;

CodePudding user response:

Top yourself!!!!!!!!!! This is the picture red statement error,,, just start playing Delphi, novice to teach! (PS: this statement a few times before I can be fully realized, but all of a sudden not, oneself try for a few days, or not, only for a great god!)

CodePudding user response:

statement error as shown in figure in,,,,

CodePudding user response:

Error could not find you in the EXCEL spreadsheet SHEET

CodePudding user response:

According to the upstairs said speculation, the Excel is not the name of the first Sheet Sheet1, changes to the other word,

CodePudding user response:

Not ah, all my Sheet name changed to Sheet1,,,, is a former Chinese characters, then in order to avoid making mistakes, all change to Sheet1.,,,,,,,,

CodePudding user response:

Well, I tried it on, if I use excel 2003 can, but not a in excel 2007,,, I would like to ask, in front of the statement "excel" 8.0 "" said what does that mean? What a great god can you explain to me in detail, thank you,,,,

CodePudding user response:

refer to 6th floor zhaping6525 response:
well, I tried it on, if I use excel 2003 can, but not a in excel 2007,,, I would like to ask, in front of the statement "excel" 8.0 "" said what does that mean? What a great god can you explain to me in detail, thank you,,,,


This problem must find Microsoft explanation to explain clearly to development of EXCEL and so on, it's better to put one hand this Microsoft provides the function description for API, the SDK reference books, and so on, is that quite a waste of paper, every this was not the kind of thick

CodePudding user response:

Learning, pass by,

CodePudding user response:

Please put the
The Provider=Microsoft. Jet. The OLEDB.
4.0Change
The provider=Microsoft. Ace. The oledb.
12.0Try
  • Related