TClientDataSet有commandtext的属性,类似query的sql,可执行数据查询并返回结果集;而SaveToFile则可以把数据以cds文件形式进行保存,建议改用clientdataset
解决方案 »
- 怎样通过语句来控制dxDBTreeList的上移下移?
- 数据回滚
- socket的问题 急 在线等待
- edit中如何屏蔽非法输入
- 在win2K使用DELPHI的QUICKREPORT做报表时,如果记录录数很少,工作正常,如果记录数多一些,比如500记会报访问地址的错误,这是为什么呢?
- 行转列数据显示保存问题,求解,
- ADO的事务处理异常。
- 我的问题好象不见了???
- delphi 6 下载?
- 我下载了delphi试用版,可是时间到期了,重装也没法,请各位指教!!!
- 三层方面的???求救,如果再得不到答案,我都快急疯了!!
- ado组件里的RDSConnection与ADOConnection有何区别?分别用在什么情况下?在局域网中和internet中,机器名都是怎样的?
Specifies the statement handle.
phCur Type: phDBICur (Output)
Pointer to the cursor handle.UsageThis function is used to execute a prepared query. If the query returns a result set, the cursor handle to the result set is returned into the address given by phCur. If the query does not generate a result set, the returned cursor handle is zero. If no cursor handle address is given and a result set would be returned, the result set is discarded. The same prepared query can be executed several times, but only after the returned cursor has been closed.
False, '"', ',', 0);
非常好用,由于用BatchMove速度很快!!procedure ExportDataSetEx(Source: TBDEDataSet; DestTable: TTable;
TableType: TTableType; const AsciiCharSet: string;
AsciiDelimited: Boolean; AsciiDelimiter, AsciiSeparator: Char;
MaxRecordCount: Longint); function ExportAsciiField(Field: TField): Boolean;
begin
Result := Field.Visible and not (Field.Calculated
{$IFDEF WIN32} or Field.Lookup {$ENDIF}) and not (Field.DataType in
ftNonTextTypes + [ftUnknown]);
end;const
TextExt = '.TXT';
SchemaExt = '.SCH';
var
I: Integer;
S, Path: string;
BatchMove: TBatchMove;
TablePath: array[0..dbiMaxPathLen] of Char;
begin
if Source = nil then DatabaseError(SDataSetEmpty);
if DestTable.Active then DestTable.Close;
if Source is TDBDataSet then
DestTable.SessionName := TDBDataSet(Source).SessionName;
if (TableType = ttDefault) then begin
if DestTable.TableType <> ttDefault then
TableType := DestTable.TableType
else if (CompareText(ExtractFileExt(DestTable.TableName), TextExt) = 0) then
TableType := ttASCII;
end;
BatchMove := TBatchMove.Create(nil);
try
StartWait;
try
BatchMove.Mode := batCopy;
BatchMove.Source := Source;
BatchMove.Destination := DestTable;
DestTable.TableType := TableType;
BatchMove.Mappings.Clear;
if (DestTable.TableType = ttASCII) then begin
if CompareText(ExtractFileExt(DestTable.TableName), SchemaExt) = 0 then
DestTable.TableName := ChangeFileExt(DestTable.TableName, TextExt);
with Source do
for I := 0 to FieldCount - 1 do begin
if ExportAsciiField(Fields[I]) then
BatchMove.Mappings.Add(Format('%s=%0:s',
[Fields[I].FieldName]));
end;
BatchMove.RecordCount := 1;
end
else BatchMove.RecordCount := MaxRecordCount;
BatchMove.Execute;
if (DestTable.TableType = ttASCII) then begin
{ ASCII table always created in "fixed" format with "ascii"
character set }
with BatchMove do begin
Mode := batAppend;
RecordCount := MaxRecordCount;
end;
S := ChangeFileExt(ExtractFileName(DestTable.TableName), '');
Path := NormalDir(ExtractFilePath(DestTable.TableName));
if Path = '' then begin
DestTable.Open;
try
Check(DbiGetDirectory(DestTable.DBHandle, False, TablePath));
Path := NormalDir(OemToAnsiStr(StrPas(TablePath)));
finally
DestTable.Close;
end;
end;
with TIniFile.Create(ChangeFileExt(Path + S, SchemaExt)) do
try
if AsciiCharSet <> '' then
WriteString(S, 'CharSet', AsciiCharSet)
else WriteString(S, 'CharSet', 'ascii');
if AsciiDelimited then begin { change ASCII-file format to CSV }
WriteString(S, 'Filetype', 'VARYING');
WriteString(S, 'Delimiter', AsciiDelimiter);
WriteString(S, 'Separator', AsciiSeparator);
end;
finally
Free;
end;
{ clear previous output - overwrite existing file }
S := Path + ExtractFileName(DestTable.TableName);
if Length(ExtractFileExt(S)) < 2 then
S := ChangeFileExt(S, TextExt);
I := FileCreate(S);
if I < 0 then
raise EFCreateError.CreateFmt(SFCreateError, [S]);
FileClose(I);
BatchMove.Execute;
end;
finally
StopWait;
end;
finally
BatchMove.Free;
end;
end;