简体   繁体   English

NSIS:页面退出功能中止后页面错误

[英]NSIS: Error in page after abort from page leave function

I've an NSIS script to copy a .NET app build and execute some scripts on an SQL DB. 我有一个NSIS脚本来复制.NET应用程序构建并在SQL DB上执行一些脚本。 I'm using xsqlexecutor tool in nsis to run these scripts after capturing sql details like instance, DB and login. 在捕获实例,数据库和登录之类的sql详细信息后,我在nsis中使用xsqlexecutor工具运行这些脚本。 These are populated from the windows registry when the nsis custom page is called. 当调用nsis自定义页面时,将从Windows注册表中填充这些内容。 The page leave function checks if it can connect to this DB successfully, and if it can't, it aborts the leave function and comes back to the page.Problem here is, when i give wrong details first time, the leave function aborts and comes back to the page, but if i give correct DB details again, it says xsqlexecutor has stopped functioning. 页面离开功能检查它是否可以成功连接到该数据库,如果不能成功,它将退出离开功能并返回页面。问题是,当我第一次输入错误的信息时,离开功能会中止并回到页面,但是如果我再次提供正确的数据库详细信息,则表示xsqlexecutor已停止运行。 However if go back a page and then hit next and come to the page again it seems to be working if i give correct DB details, 但是,如果返回上一页然后单击下一步并再次进入该页面,如果我提供正确的数据库详细信息,它似乎可以正常工作,

    Function SqlConfigPage
         SectionGetFlags ${SEC03} $R0
         IntOp $R0 $R0 & ${SF_SELECTED}
         IntCmp $R0 ${SF_SELECTED} show
         Abort

show:
 nsDialogs::Create /NOUNLOAD 1018
 Pop $Dialog
 ${If} $Dialog == error
  Abort
 ${EndIf}
 ${NSD_CreateLabel} 0 0 100% 15u "Enter SQL Details"
   Pop $Label

   ${NSD_CreateLabel} 0 15u 50u 12u "Server Instance"
   Pop $Server

    ${NSD_CreateText} 60u 15u 100% 12u "$instance"
   Pop $instance

   ${NSD_CreateLabel} 0 30u 36u 12u "SQL DB"
   Pop $dblabel

   ${NSD_CreateText} 36u 30u 100% 12u "$db"
   Pop $db

   ${NSD_CreateLabel} 0 45u 36u 12u "Username"
   Pop $userlabel

   ${NSD_CreateText} 36u 45u 100% 12u "$user"
   Pop $user

   ${NSD_CreateLabel} 0 60u 36u 12u "Password"
   Pop $Passwordlabel

   ${NSD_CreatePassword} 36u 60u 100% 12u "$pwd"
   Pop $pwd
                nsDialogs::Show

FunctionEnd

Function SqlConfigPageLeave

 ${NSD_GetText} $Server $R1
 ${NSD_GetText} $db $R2
 ${NSD_GetText} $user $R3
 ${NSD_GetText} $pwd $R4
 StrCpy $server $R1
 StrCpy $db $R2
 StrCpy $user $R3
 StrCpy $pwd $R4

InitPluginsDir
SetOutPath "$PLUGINSDIR"
SetOverwrite On
  CreateDirectory $PLUGINSDIR\SQL
  SetOutPath "$PLUGINSDIR\SQL"
  File /nonfatal "..\xsql.exe"
  File /nonfatal "..\sqlconnectioncheck.txt"
  nsExec::Exec '$PLUGINSDIR\SQL\xsql.exe /s:$R1 /d:$R2 /t:false /u:$R3 /p:$R4 /m:3 /q /f:"$PLUGINSDIR\SQL\sqlconnectioncheck.txt"'
   IfFileExists $PLUGINSDIR\SQL\ScriptErr.txt sqlerror continue
 sqlerror:
 FileOpen $7 "$PLUGINSDIR\Scripts\ScriptErr.txt" r
 FileRead $7 $8
 FileRead $7 $9
 FileClose $7
  MessageBox MB_OK "SQL Connetion failed, check SQL details provided once again. $8 $9"

continue:
FunctionEnd

any input would be helpful, thanks a lot in advance.. 任何输入都会有所帮助,非常感谢。

Seems, you are rewriting controls handles at -Leave function.: 似乎您正在-Leave函数上重写控件句柄:

 StrCpy $server $R1
 StrCpy $db $R2
 StrCpy $user $R3
 StrCpy $pwd $R4

Thus, at second invoking you always get trash in parameters: 因此,在第二次调用时,您总是在参数中遇到垃圾:

 ${NSD_GetText} $Server $R1
 ${NSD_GetText} $db $R2
 ${NSD_GetText} $user $R3
 ${NSD_GetText} $pwd $R4

Because $Server,$db, $user, $pwd contains previous values instead of control handles. 因为$ Server,$ db,$ user,$ pwd包含以前的值而不是控制句柄。

Use separate variables for controls and its values, something like this: 为控件及其值使用单独的变量,如下所示:

Var server_ctrl
Var db_ctrl
Var user_ctrl
Var pwd_ctrl
     Function SqlConfigPage
             SectionGetFlags ${SEC03} $R0
             IntOp $R0 $R0 & ${SF_SELECTED}
             IntCmp $R0 ${SF_SELECTED} show
             Abort

    show:
 nsDialogs::Create /NOUNLOAD 1018
 Pop $Dialog
 ${If} $Dialog == error
  Abort
 ${EndIf}
 ${NSD_CreateLabel} 0 0 100% 15u "Enter SQL Details"
   Pop $Label

   ${NSD_CreateLabel} 0 15u 50u 12u "Server Instance"
   Pop $Server_ctrl

    ${NSD_CreateText} 60u 15u 100% 12u "$instance"
   Pop $instance

   ${NSD_CreateLabel} 0 30u 36u 12u "SQL DB"
   Pop $dblabel

   ${NSD_CreateText} 36u 30u 100% 12u "$db"
   Pop $db_ctrl

   ${NSD_CreateLabel} 0 45u 36u 12u "Username"
   Pop $userlabel

   ${NSD_CreateText} 36u 45u 100% 12u "$user"
   Pop $user_ctrl

   ${NSD_CreateLabel} 0 60u 36u 12u "Password"
   Pop $Passwordlabel

   ${NSD_CreatePassword} 36u 60u 100% 12u "$pwd"
   Pop $pwd_ctrl
                nsDialogs::Show

FunctionEnd

Function SqlConfigPageLeave

 ${NSD_GetText} $Server_ctrl $R1
 ${NSD_GetText} $db_ctrl $R2
 ${NSD_GetText} $user_ctrl $R3
 ${NSD_GetText} $pwd_ctrl $R4
 StrCpy $server $R1
 StrCpy $db $R2
 StrCpy $user $R3
 StrCpy $pwd $R4

InitPluginsDir
SetOutPath "$PLUGINSDIR"
SetOverwrite On
  CreateDirectory $PLUGINSDIR\SQL
  SetOutPath "$PLUGINSDIR\SQL"
  File /nonfatal "..\xsql.exe"
  File /nonfatal "..\sqlconnectioncheck.txt"
  nsExec::Exec '$PLUGINSDIR\SQL\xsql.exe /s:$R1 /d:$R2 /t:false /u:$R3 /p:$R4 /m:3 /q /f:"$PLUGINSDIR\SQL\sqlconnectioncheck.txt"'
   IfFileExists $PLUGINSDIR\SQL\ScriptErr.txt sqlerror continue
 sqlerror:
 FileOpen $7 "$PLUGINSDIR\Scripts\ScriptErr.txt" r
 FileRead $7 $8
 FileRead $7 $9
 FileClose $7
  MessageBox MB_OK "SQL Connetion failed, check SQL details provided once again. $8 $9"

continue:
FunctionEnd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM