Announcement

Collapse
No announcement yet.

Building SQL Databse

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • benjasperson
    replied
    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.

    Leave a comment:


  • Anders
    replied
    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:


  • benjasperson
    replied
    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:


  • benjasperson
    replied
    I don't think I understand your suggestion. I replaced the line containing ExecWait with these two lines:
    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'

    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.

    Leave a comment:


  • Anders
    replied
    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:


  • benjasperson
    started a topic Building SQL Databse

    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:
    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

    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.
Working...
X
😀
🥰
🤢
😎
😡
👍
👎