![]() |
#1 |
Junior Member
Join Date: Oct 2018
Posts: 7
|
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.
code: I don't think I'm missing any necessary SQLCMD files because I can build the database when just run SQLCMD from command line. Thanks in advance for the help. |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
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...
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Oct 2018
Posts: 7
|
I don't think I understand your suggestion. I replaced the line containing ExecWait with these two lines:
code: 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. |
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Oct 2018
Posts: 7
|
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. |
![]() |
![]() |
![]() |
#5 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
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.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#6 |
Junior Member
Join Date: Oct 2018
Posts: 7
|
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. |
![]() |
![]() |
![]() |
|
Tags |
database, sqlcmd |
Thread Tools | Search this Thread |
Display Modes | |
|
|