source
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, JvExControls, JvNavigationPane, Buttons, ComCtrls;
type
TForm2 = class(TForm)
Button1: TButton; JvNavPanelHeader1: TJvNavPanelHeader;
Shape26: TShape; ProgressBar1: TProgressBar;
Label1: TLabel; Label2: TLabel;
Label3: TLabel; Button2: TButton;
procedure Label2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
row_curr,row_all:integer;
sconnection:string; // variable for hold connection string
st:string; // variable for hold any string
ImportFileName: String; // variable for Access address file part
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
row_curr:=0;row_all:=0;
//-------------------------------------------------//|
zquery.close; //|
zquery.sql.text:='delete from tempreport '; //|
zquery.execsql; //|
zquery.close; //|
zquery.sql.text:='select * from tempreport '; //|
zquery.open; //|
//------------------------------------------------ //|
//-----------------------------------------------------------------------------------------------------------//|
ImportFileName := fileopendialog('Access|*.mdb'); //|
if not FileExists(ImportFileName) then raise exception.create(' ¡ÃسҵÃǨÊͺ ä¿Åì '+ImportFileName); //|
setcursorbusy(true); //|
// showmessage('¹Óà¢éÒ '+ImportFileName); //|
sconnection:=' Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;'+ //|
'Data Source= ' + ImportFileName + ' ; ' + //|
'Mode=Share Deny None;Extended Properties="";Jet OLEDB:System database="";'+ //|
'Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;'+ //|
'Jet OLEDB:Database Locking Mode=1;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; '; //|
//---------------------------------------------------------------------------------------------------------- //|
//-------------------------------------------------------//|
jconnection.connected:=false; //|
jconnection.protocol:='ado'; //|
jconnection.database:=sconnection; //|
jconnection.connected:=true; //|
jquery.close; //|
jquery.sql.text:='select * from UCdata '; //|
jquery.open; //|
//-------------------------------------------------------//|
while not jquery.eof do //start loop for while
begin
row_curr:=row_curr+1;
label1.caption:=inttostr(row_curr);
label2.caption:=inttostr(row_curr);
label3.caption:=inttostr(row_curr);
setprogressbar(row_curr,row_curr+500);
setstatuslabel('Progress ... '+inttostr(row_curr)+'/'+inttostr(200) );
//------------------------------------------------------
zquery.insert;
zquery.fieldbyname('name1').asstring:=jquery.fieldbyname('HINDEX').asstring; // showmessage(jquery['hindex']);
zquery.fieldbyname('name2').asstring:=jquery.fieldbyname('Pid').asstring;
zquery.fieldbyname('name3').asstring:=jquery.fieldbyname('MASTERCUPID').asstring;
zquery.fieldbyname('name4').asstring:=jquery.fieldbyname('TITLE').asstring;
zquery.fieldbyname('name5').asstring:=jquery.fieldbyname('FNAME').asstring;
zquery.fieldbyname('name6').asstring:=jquery.fieldbyname('LNAME').asstring;
zquery.fieldbyname('name7').asstring:=jquery.fieldbyname('SEX').asstring;
zquery.fieldbyname('date1').asstring:=jquery.fieldbyname('BIRTHDATE').asstring;
zquery.fieldbyname('name8').asstring:=jquery.fieldbyname('AGE').asstring;
zquery.fieldbyname('name9').asstring:=jquery.fieldbyname('SUBINSCL').asstring;
zquery.fieldbyname('name10').asstring:=jquery.fieldbyname('HMAIN').asstring;
zquery.fieldbyname('name11').asstring:=jquery.fieldbyname('HSUB').asstring;
zquery.fieldbyname('name12').asstring:=jquery.fieldbyname('STATUS').asstring;
zquery.fieldbyname('name13').asstring:=jquery.fieldbyname('CARDID').asstring;
zquery.fieldbyname('date2').asstring:=jquery.fieldbyname('NOTEDATE').asstring;
zquery.fieldbyname('date3').asstring:=jquery.fieldbyname('STARTDATE').asstring;
zquery.fieldbyname('date4').asstring:=jquery.fieldbyname('EXPDATE').asstring;
zquery.fieldbyname('name14').asstring:=jquery.fieldbyname('PROCODE').asstring;
zquery.fieldbyname('name15').asstring:=jquery.fieldbyname('OWNERPURCHASE').asstring;
zquery.fieldbyname('name16').asstring:=jquery.fieldbyname('MAININSCL').asstring;
zquery.fieldbyname('name17').asstring:=jquery.fieldbyname('NOTE').asstring;
zquery.fieldbyname('name18').asstring:=jquery.fieldbyname('NATION').asstring;
zquery.fieldbyname('name19').asstring:=jquery.fieldbyname('OCCUPA').asstring;
zquery.fieldbyname('name20').asstring:=jquery.fieldbyname('ADDRESS').asstring;
zquery.fieldbyname('name21').asstring:=jquery.fieldbyname('MOO').asstring;
zquery.fieldbyname('name22').asstring:=jquery.fieldbyname('ROAD').asstring;
zquery.fieldbyname('name23').asstring:=jquery.fieldbyname('TAMBON').asstring;
zquery.fieldbyname('name24').asstring:=jquery.fieldbyname('AMPHUR').asstring;
zquery.fieldbyname('x1').asstring:=jquery.fieldbyname('PROVINCE').asstring;
zquery.fieldbyname('x2').asstring:=jquery.fieldbyname('ZIPCODE').asstring;
zquery.fieldbyname('x3').asstring:=jquery.fieldbyname('RESULT_ID').asstring;
zquery.fieldbyname('x4').asstring:=jquery.fieldbyname('WelUC_ID').asstring;
zquery.fieldbyname('x5').asstring:=jquery.fieldbyname('Paid_Model').asstring;
zquery.fieldbyname('x6').asstring:=jquery.fieldbyname('RegisterID').asstring;
zquery.fieldbyname('x7').asstring:=jquery.fieldbyname('Flag').asstring;
zquery.fieldbyname('x8').asstring:=jquery.fieldbyname('Hmain_OP').asstring;
zquery.fieldbyname('x9').asstring:=jquery.fieldbyname('Type_Register').asstring;
zquery.fieldbyname('x10').asstring:=jquery.fieldbyname('Status_Frm').asstring;
zquery.fieldbyname('name').asstring:=jquery.fieldbyname('Status_Reg').asstring;
zquery.post;
//-------------------------------------------------------
jquery.next;
end;
setprogressbar(row_curr,row_curr);
showmessage('Import OK');
jquery.close;
zquery.close;
setcursorbusy(false);
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
end;
end.