Old 5th October 2022, 13:12   #1
aNoNameMoose
Junior Member
 
Join Date: Jan 2022
Posts: 4
Check DB Connection from Installer

Hello!

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
FunctionEnd

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?
aNoNameMoose is offline   Reply With Quote
Old 5th October 2022, 14:13   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,542
If your installer is Unicode you need to use UMSSQL_OLEDB?

Make sure the server name is correct.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th October 2022, 14:23   #3
aNoNameMoose
Junior Member
 
Join Date: Jan 2022
Posts: 4
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
aNoNameMoose is offline   Reply With Quote
Old 5th October 2022, 17:29   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,542
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
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump