No announcement yet.

Check DB Connection from Installer

  • Filter
  • Time
  • Show
Clear All
new posts

  • Check DB Connection from Installer


    I have the current problem at hand.
    I have a nicely working installer with several custom pages, mostly to configure some services we install.
    I have a page that has fields that can be filled out that we will use to create a database connection. (The full connection string is assembled by a powershell script)
    I would like to have a button on the page (this part is done) and have it's OnClick function check if the data that was filled in can make a successful connection to the database.

    Function OnClick
    MSSQL_OLEDB::SQL_Logon "servername\sqlexpress" "username" "password"
    Pop $0
    MessageBox MB_OK|MB_ICONSTOP "You clicked me and the result was $0" /SD IDOK

    According to the plugins' very miniscule documentation I always get the error code, 1
    I'm not sure what I'm doing wrong.
    Is it not compatible? I have 2019 SQL Express server installed
    It's configured for mixed authentication (windows/sql server), I tried both in the installer, always get the error code 1.
    Any tips?

  • #2
    If your installer is Unicode you need to use UMSSQL_OLEDB?

    Make sure the server name is correct.
    IntOp $PostCount $PostCount + 1


    • #3
      Thank you, that worked for both authentication types.
      I feel silly for not trying it earlier.

      If I may ask another question, how do I tell if something is Unicode or not? What does that mean?
      I know it's to do with encoding characters but I guess I'm not grasping what it really means


      • #4
        DOS and Windows 95/98 uses "ANSI" codepages and so does NSIS v2 (and NSIS v3 with "Unicode False"). Typically 1 byte per "character".

        NSIS v3 now defaults to Unicode. On Windows this uses the UTF-16LE encoding, typically 2 bytes per "character".

        Unicode supports all languages and character scripts. Windows NT and later has two versions of all functions that take a string as input/output, one for ANSI codepages and one for Unicode. When using plug-ins, they must match the character encoding of the installer...
        IntOp $PostCount $PostCount + 1