作用:将用户对象导出txt,以对象名为文件名,将对应内容写入相应的文件中
//////////////////////
函数:循环导出用户对象
////////////////////
procedure TForm1.SaveMIErrorid(pname,pcolumn,ptype,plength,nullable,newserver_oldserver: string);
var lHandle:THandle;
lFName,lStr:string;
lLen,num:DWord;
begin
// Result :=0;
lFName :=ExtractFilePath(Application.ExeName)+newserver_oldserver+''/''+pname+''.Txt'';
if not FileExists(lFName) then
lHandle:=CreateFile(pchar(lFName), GENERIC_READ+GENERIC_WRITE,FILE_SHARE_READ+FILE_SHARE_WRITE, nil,
CREATE_NEW,FILE_ATTRIBUTE_NORMAL+FILE_FLAG_RANDOM_ACCESS, 0)
else
lHandle:=CreateFile(pchar(lFName), GENERIC_READ+GENERIC_WRITE,FILE_SHARE_READ+FILE_SHARE_WRITE, nil,
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL+FILE_FLAG_RANDOM_ACCESS, 0);
if (lHandle = INVALID_HANDLE_VALUE) then
begin
CloseHandle(lHandle);
Exit;
end;
try
lStr:=pcolumn+ptype+plength+nullable+#13 + #10;
lLen:=Length(lStr);
SetFilePointer(lHandle,0 ,nil,FILE_END);
WriteFile(lHandle,lStr,lLen,num,nil);
FlushFileBuffers(lHandle);
finally
CloseHandle(lHandle);
end;
调用函数:
procedure TForm1.N11Click(Sender: TObject);
var
name_srt,type_srt,column_str,length_str,nullable_str:string;
str:string;
begin
adoquery1.Connection:=DataModule2.ADOConnection1;
adoquery1.Close;
adoquery1.SQL.Text := ''select table_name,column_name,data_type,data_length,nullable from sys.dba_tab_cols where owner=upper(''''''+str_userID+'''''') and table_name not like ''''%