菜单

ADO连接MS SQL SEHavalVETiggo 二〇〇四前后相继

2020年3月26日 - 数据库

ado连接ms sql server 2000程序

implementation

function adothread(param: pointer): integer; stdcall;var con, cmd :
variant;begin coinitialize(nil); con := getnewconnection(…); if
varisempty(con) then begin //未连接上,退出 exit; end eles cmd :=
getnewcommand(con) while bterminate do begin if varisempty(con) then
//连接失败 退出 exit else sleep(1000); end; closeconnection(con);
//自定义的关闭函数。 其实测试时, cmd := unassigned; couninitialize;
result := 0;end;

type
TForm1 = class(TForm)
cds: TClientDataSet;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
procedure ExportData(const tableNames: string);
procedure ImportData(const fileName, tableNames: string);
public
{ Public declarations }
end;

unit Unit1;

procedure TForm1.Button2Click(Sender: TObject);
begin
ImportData(ExtractFilePath(Application.ExeName) + ‘export.sql’,
‘bas_kind,bas_goods’);
end;

end.

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Data.DB,
Datasnap.DBClient;

procedure TForm1.ExportData(const tableNames: string);
var
sql, err: string;
sl, tables: TStringList;
i, h: Integer;
fieldNames, values: string;
function GetValue(field: TField): string;
begin
case field.DataType of
ftString, ftTimeStamp:
begin
Result := QuotedStr(field.AsString);
end;
ftBoolean:
begin
case field.AsBoolean of
true: Result := ‘1’;
false: Result := ‘0’;
end;
end;
else
if not VarIsNull(field.Value) then
begin
Result := VarToStr(field.Value);
end
else
Result := ‘null’;
end;
end;

interface

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图