将数据导出至 M$ Access
Dev Express 中的 dxDBGrid/cxGrid 均提供了将表格中 数据 导出 到 M$ Excel 等中的方法,但大多时候,却需将 数据 导出 至 M$ Access 中... 于是便有了本文。 uses ComObj, Gauges, ShellAPI; const ExportTabName_MDB = '营销 数据 '; MDBStr = 'Provider=
Dev Express 中的 dxDBGrid/cxGrid 均提供了将表格中数据导出到 M$ Excel 等中的方法,但大多时候,却需将数据导出至 M$ Access 中... ADelphiCoder
于是便有了本文。
uses
ComObj, Gauges, ShellAPI;
const
ExportTabName_MDB = '营销数据';
MDBStr = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s';
var
ExportName: string;
ExportColumnLst: TStringList; //列名;列类型(长度)
begin
ExportName:= '导出结果.MDB'; //use a SaveDialog to select the save name here
ExportColumnLst:= TStringList.Create;
//(示例)导出列列表,注意 格式
ExportColumnLst.Add('Contact;联系人 varchar(30)');
ExportColumnLst.Add('Gender;性别 varchar(2)');
ExportColumnLst.Add('Address;地址 varchar(100)');
ExportColumnLst.Add('PostCode;邮编 varchar(6)');
try
ExportToMDB(ExportName, ExportColumnLst);
finally
FreeAndNil(ExportColumnLst);
end;
end;
procedure ExportToMDB(ExportMDBName: string; ExportColumnLst);
function CreateMDB(MDBFileName: string): Boolean;
var
vMDB: Variant;
begin
Result:= False;
vMDB:= CreateOleObject('ADOX.Catalog');
vMDB.Create(Format(MDBStr, [MDBFileName]));
vMDB:= UnAssigned;
Result:= True;
end;
function CreateTab(MDBAndTabName: string; ExportColumnLst: TStringList;
aqy_ExecSQL: TADOQuery): Boolean;
var
i: Integer;
StrTmp: string;
SQLTxt: string;
MDBName: string;
TabName: string;
begin
Result:= False;
SQLTxt:= '';
for i:= 0 to ExportColumnLst.Count - 1 do
begin
StrTmp:= ExportColumnLst.Strings
if SQLTxt = '' then
SQLTxt:= Copy(StrTmp, Pos(';', StrTmp) + 1, Length(StrTmp));
else
SQLTxt:= SQLTxt + ',' +
Copy(StrTmp, Pos(';', StrTmp) + 1, Length(StrTmp));
end;
MDBName:= Copy(MDBAndTabName, 1, Pos(';', MDBAndTabName) - 1);
TabName:= Copy(
MDBAndTabName,
Pos(';', MDBAndTabName) + 1,
Length(MDBAndTabName)
);
with aqy_ExecSQL do
try
Close;
ConnectionString:=
'Provider=MSDataShape.1;Data Provider=Microsoft.Jet.OLEDB.4.0;' +
'Data Source=' + MDBName + ';Persist Security Info=false';
SQL.Text:=
'create table ' + TabName +
'(' +
SQLTxt +
')';
try
ExecSQL;
Close;
except
on E: Exception do
begin
MessageBox(
Handle,
PChar('创建表失败!' + #13 + '失败原因:' + E.Message),
'错误',
MB_OK + MB_ICONERROR
);
Close;
Exit;
end;
end;
finally
//Free;
end;
Result:= True;
end;
var
aqy_ExecSQL: TADOQuery;
SQLTxt: string;
i: Integer;
StrTmp: string;
ExportColumn: string;
ExportColumnParam: string;
ExportParamLst: TStringList;
GgTip: TGauge;
CurrRec: Integer;
begin
if CreateMDB(ExportMDBName) then
begin
aqy_ExecSQL:= TADOQuery.Create(Self);
try
if CreateTab(
ExportMDBName + ';' + ExportTabName_MDB,
ExportColumnLst,
aqy_ExecSQL
) then
begin
Screen.Cursor:= crHourGlass;
ExportColumn:= '';
ExportColumnParam:= '';
ExportParamLst:= TStringList.Create;
for i:= 0 to ExportColumnLst.Count - 1 do
begin
StrTmp:= ExportColumnLst.Strings
if ExportColumn = '' then
begin
ExportColumn:= Copy(StrTmp, 1, Pos(';', StrTmp) - 1);
ExportColumnParam:= ':' + ExportColumn;
ExportParamLst.Add(ExportColumn);
end
else
begin
ExportColumn:= ExportColumn + ',' +
Copy(StrTmp, 1, Pos(';', StrTmp) - 1);
ExportColumnParam:= ExportColumnParam + ',:' +
Copy(StrTmp, 1, Pos(';', StrTmp) - 1);
ExportParamLst.Add(Copy(StrTmp, 1, Pos(';', StrTmp) - 1));
end;
end;
SQLTxt:=
'select ' + ExportColumn + ' from TabName where ID=' +
aqy_Tmp1.FieldByName('ID').AsString;
try
with aqy_ExportData do //aqy_ExportData: TADOQuery;
begin
Close;
SQL.Text:= SQLTxt;
Open;
//pnl_ExportFile: TPanel;
GgTip:= TGauge.Create(pnl_ExportFile); //Gauge 进度提示
with GgTip do
begin
Parent:= pnl_ExportFile;
Left:= 0;
Height:= 21;
Width:= pnl_ExportFile.Width;
ForeColor:= clFuchsia;
MinValue:= 0;
MaxValue:= RecordCount;
Visible:= True;
Update;
end;
CurrRec:= 0;
while not Eof do
begin
Inc(CurrRec);
if CurrRec mod 20 = 0 then
begin
GgTip.Progress:= CurrRec;
Update;
Application.ProcessMessages;
end;
with aqy_ExecSQL do
begin
Close;
SQL.Text:=
'Insert Into ' + ExportTabName_MDB +
' Values(' + ExportColumnParam + ')';
for i:= 0 to ExportParamLst.Count - 1 do
Parameters.ParamByName(ExportParamLst.Strings
aqy_ExportData.FieldByName(
ExportParamLst.Strings
).AsString;
try
ExecSQL;
except
on E: Exception do
begin
Close;
GgTip.Visible:= False;
Update;
MessageBox(
Handle,
PChar('导出文件失败! ' + #13 + '失败原因:' +
E.Message + ' '
),
'错误',
MB_OK + MB_ICONERROR
);
Exit;
end;
end;
end; //End with
aqy_ExecSQL.Close;
Next;
end; //End while
Close; //aqy_ExportData
GgTip.Visible:= False;
if MessageBox(
Handle,
PChar('导出文件成功! ' + #13 +
'现在查看导出结果(' + ExportMDBName + '吗?'
),
'提示',
MB_YESNO + MB_ICONINFORMATION
) = IDYES then
begin
ShellExecute(0, 'Open', PChar(ExportMDBName), nil, nil, SW_SHOW);
end;
end;
except
on E: Exception do
begin
pnl_ExportFile.Caption:= '';
GgTip.Visible:= False;
Update;
MessageBox(
Handle,
PChar('导出文件过程中发生错误! ' + #13 +
'错误描述:' + E.Message + ' '
),
'导出失败',
MB_OK + MB_ICONERROR
);
end;
end;
end;
finally
FreeAndNil(aqy_ExecSQL);
FreeAndNil(ExportParamLst);
FreeAndNil(GgTip);
Screen.Cursor:= crDefault;
end;
end;
end;
OK,Done!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

SQL IF statements are used to conditionally execute SQL statements, with the syntax as: IF (condition) THEN {statement} ELSE {statement} END IF;. The condition can be any valid SQL expression, and if the condition is true, execute the THEN clause; if the condition is false, execute the ELSE clause. IF statements can be nested, allowing for more complex conditional checks.

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

Methods to solve the cross-domain problem of Vue Axios include: Configuring the CORS header on the server side using the Axios proxy using JSONP using WebSocket using the CORS plug-in

The main reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.

The advantage of multithreading is that it can improve performance and resource utilization, especially for processing large amounts of data or performing time-consuming operations. It allows multiple tasks to be performed simultaneously, improving efficiency. However, too many threads can lead to performance degradation, so you need to carefully select the number of threads based on the number of CPU cores and task characteristics. In addition, multi-threaded programming involves challenges such as deadlock and race conditions, which need to be solved using synchronization mechanisms, and requires solid knowledge of concurrent programming, weighing the pros and cons and using them with caution.

The key to PHPMyAdmin security defense strategy is: 1. Use the latest version of PHPMyAdmin and regularly update PHP and MySQL; 2. Strictly control access rights, use .htaccess or web server access control; 3. Enable strong password and two-factor authentication; 4. Back up the database regularly; 5. Carefully check the configuration files to avoid exposing sensitive information; 6. Use Web Application Firewall (WAF); 7. Carry out security audits. These measures can effectively reduce the security risks caused by PHPMyAdmin due to improper configuration, over-old version or environmental security risks, and ensure the security of the database.

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

VprocesserazrabotkiveB-enclosed, Мнепришлостольностьсясзадачейтерациигооглапидляпапакробоглесхетсigootrive. LEAVALLYSUMBALLANCEFRIABLANCEFAUMDOPTOMATIFICATION, ČtookazaLovnetakProsto, Kakaožidal.Posenesko
