Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sqlcmd在inno安装程序内不工作,即使结果代码等于零_Sql_Sql Server_Installation_Inno Setup - Fatal编程技术网

sqlcmd在inno安装程序内不工作,即使结果代码等于零

sqlcmd在inno安装程序内不工作,即使结果代码等于零,sql,sql-server,installation,inno-setup,Sql,Sql Server,Installation,Inno Setup,在谷歌搜索了一堆东西,挣扎了一天却没有结果之后,我终于来了。 我正在使用Inno安装程序开发一个安装程序,它根据包含复选框的向导页面中的一些用户输入来安装并正确配置MS SQL Server 2008 R2 我有一个执行SQL Server配置的过程,如下所示: Source: ".\src\{#ExecName}"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: runSQLCMD 其中#ExecName是我的.exe名称 程序如

在谷歌搜索了一堆东西,挣扎了一天却没有结果之后,我终于来了。 我正在使用Inno安装程序开发一个安装程序,它根据包含复选框的向导页面中的一些用户输入来安装并正确配置MS SQL Server 2008 R2

我有一个执行SQL Server配置的过程,如下所示:

Source: ".\src\{#ExecName}"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: runSQLCMD
其中#ExecName是我的.exe名称

程序如下:



    [Code]
    procedure runSQLCMD();
    var
        ResultCode: Integer;
        SQLCMDPath: String;
        SQLParams: String;
        BasicQuery: String;
        FullQuery: String;
    begin
        SQLCMDPath := ExpandConstant('{pf}') + '\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe'

        BasicQuery := 'EXEC sp_configure ''show advanced option'', 1; RECONFIGURE; EXEC sp_configure ''max worker threads'', 256; RECONFIGURE; EXEC sp_configure ''backup compression default'', 1; RECONFIGURE; EXEC sp_configure ''max degree of parallelism'', 4; RECONFIGURE; EXEC sp_configure ''max server memory'', 512; RECONFIGURE;';

        FullQuery := 'EXEC sp_configure ''show advanced option'', 1; RECONFIGURE; EXEC sp_configure ''backup compression default'', 1; RECONFIGURE; EXEC sp_configure ''max degree of parallelism'', 4; RECONFIGURE; EXEC sp_configure ''max server memory'', 1024; RECONFIGURE;';

        if not FileExists(SQLCMDPath) then begin
            SQLCMDPath := ExpandConstant('{pf64}') + '\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe'
        end;
        if (ShouldRunItem(1)) then begin
            SQLParams := '-S .\INSTANCE -U sa -P "password" -Q "' + BasicQuery + '-o ' + ExpandConstant('{tmp}') + '\logsql.txt';
            if (Exec(SQLCMDPath, SQLParams, '',SW_SHOW,ewWaitUntilIdle, ResultCode)) then begin
                MsgBox('Success!', mbInformation, MB_OK);
            end
            else begin
                MsgBox('Error', mbError, MB_OK);
            end;    
        end;
        if (ShouldRunItem(2)) then begin
            SQLParams := '-S .\INSTANCE -U sa -P "password" -Q "' + FullQuery + '-o ' + ExpandConstant('{tmp}') + '\logsql.txt';
            if (Exec(SQLCMDPath, SQLParams, '',SW_SHOW,ewWaitUntilIdle, ResultCode)) then begin
                MsgBox('Success!', mbInformation, MB_OK);
            end
            else begin
                MsgBox('Error', mbError, MB_OK);
            end;
        end;
    end;

当Exec语句运行时,ResultCode变量在调试时返回零,但当我右键单击服务器,指向属性/内存(在SSM上)时,内存配置不会使用用户选择的值进行设置。甚至没有生成logsql.txt文件(我打开了由{tmp}常量指向的目录,那里没有.txt文件)

从cmd运行sqlcmd,使用相同的参数和查询,一切正常

我做错了什么

先谢谢你