说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

如何在delphi中执行table.sql文件?

编辑:说三道四文库 发布时间:2018-06-23 06:03
HTML文档下载 WORD文档下载 PDF文档下载
如何在delphi中执行table.sql文件?
我的table.sql文件有500k,上万行。
Tstringlist读取 然后判断是不是'GO'是则执行的 否则的话继续读取然后...
用adocommand吗?太慢好像死机了一样,有没有好用点的,能替代adocommand的东东
在程序中运行数据库脚本,以便生成实用库
 如var
    FilePath:string;//文件路径
    siStartupInfo:STARTUPINFO;
    saProcess,saThread:SECURITY_ATTRIBUTES; 
    fSuccess:boolean;           
    piProcInfoGPS:PROCESS_INFORMATION;       


begin 
 FilePath:=extractfilepath(application.ExeName)+'table.sql';
    filepath:='osql /U '+SQLName+' /P '+SQLpassword+' /d '+' test /i '+Filepath;
    winexec(pchar(FilePath),SW_HIDE);
    ZeroMemory(@siStartupInfo,sizeof(siStartupInfo));
    siStartupInfo.cb:=sizeof(siStartupInfo);
    siStartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
    siStartupInfo.wShowWindow:=SW_HIDE;
    saProcess.nLength:=sizeof(saProcess);
    saProcess.lpSecurityDescriptor:=PChar(nil);
    saProcess.bInheritHandle:=true;
    saThread.nLength:=sizeof(saThread);
    saThread.lpSecurityDescriptor:=PChar(nil);
    saThread.bInheritHandle:=true;
    fSuccess:=CreateProcess(PChar(nil),  //指向一个以空结尾的串,他指定了要执行的模块
                            pchar(filepath), //指向一个以空结尾的串,该串定义了要执行的命令行
                            @saProcess,
                            @saThread,
                            false,
                            CREATE_DEFAULT_ERROR_MODE,
                            Pchar(nil),
                            Pchar(nil),
                            siStartupInfo,
                            piProcInfoGPS);
end;

up
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘