Solution:
It turns out I was doing a couple of things together to cause this issue. First, I forgot to delete the output.txt file I made in a test run before compiling the .nsi file, so the installer was loading that and reading it. Second, I was thinking that my SQLCMD directory was the working directory. Once I added the file path before the file names, things started working.
Thanks for the help.
Announcement
Collapse
No announcement yet.
Building SQL Databse
Collapse
X
-
I meant just ExecWait '"cmd.exe" /K' so you can run your command manually in that terminal to see if it works. It is unlikely that ExecWait is the issue.
Leave a comment:
-
UPDATE: Building SQL Databse
I've started seeing errors again, but they seem random. For example, if I misspell the name of the computer, I would expect to get a failed connection error. Instead, I keep getting an error that the .mdf (referenced inside the createdbonfile.sql file) cannot be opened.
I even tried replacing '-i createdbonfile.sql' with '-Q "SELECT 1"'. Even though there is no reason sqlcmd should be trying to access that .mdf anymore, I still get the error that it cannot be opened.
Leave a comment:
-
I don't think I understand your suggestion. I replaced the line containing ExecWait with these two lines:
Doing this I got pretty much the same outcome. Of course, I had to indicate the location of createdbonfile.sql since I was working from the directory where cmd.exe was located.code:
MessageBox mb_ok '"$PLUGINSDIR\SQLCMD\sqlcmd.exe" -S Cmp-000000\SQLEXPRESS -i createdbonfile.sql -o output.txt'
ExecWait '"cmd.exe" /K $PLUGINSDIR\SQLCMD\sqlcmd.exe -S Cmp-000000\SQLEXPRESS -i $PLUGINSDIR\SQLCMD\createdbonfile.sql -o output.txt'
Leave a comment:
-
Change "ExecWait" to "MessageBox mb_ok". As the next line, add "ExecWait 'cmd.exe /k'" and the copy the command-line from the messagebox and try it in the terminal and see what happens...
Leave a comment:
-
Building SQL Databse
I'm trying to use SQLCMD in an installer to build a local database. At one point, I was at least able to display the SQL errors, and after removing only (as far as I can remember) unrelated lines of code, I can't even see the errors. I know SQLCMD is still doing something because the output.txt file is being created. It's just blank. There are obviously errors because (and of course, this is the main issue) the database is not being created.
I don't think I'm missing any necessary SQLCMD files because I can build the database when just run SQLCMD from command line.code:
OutFile "db_installer.exe"
!include psexec.nsh
!include LogicLib.nsh
Section
InitPluginsDir
SetOutPath $PLUGINSDIR
File /r SQLCMD
ExecWait '"$PLUGINSDIR\SQLCMD\sqlcmd.exe" -S Cmp-000000\SQLEXPRESS -i createdbonfile.sql -o output.txt'
FileOpen $4 "$PLUGINSDIR\SQLCMD\output.txt" r
FileSeek $4 0
ClearErrors
${DoUntil} ${Errors}
FileRead $4 $1
DetailPrint $1
${LoopUntil} 1 = 0
FileClose $4
# default section end
SectionEnd
Thanks in advance for the help.
Leave a comment: