MSSQL OLEDB plug-in: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (→Description) |
No edit summary |
||
Line 11: | Line 11: | ||
'''Version:''' 1.0 12th March 2007. First Release<br> | '''Version:''' 1.0 12th March 2007. First Release<br> | ||
'''Version:''' 1.1 20th March 2007. Fixed bug in DllMain under Windows 2000<br> | '''Version:''' 1.1 20th March 2007. Fixed bug in DllMain under Windows 2000<br> | ||
'''Version:''' 1.2 29th March 2007. Added SQL_ExecuteScript function<br> | |||
'''Supported on:''' ''Windows NT, Windows 2000, Windows XP''. | '''Supported on:''' ''Windows NT, Windows 2000, Windows XP''. | ||
Line 39: | Line 40: | ||
;Excecutes a SQL query | ;Excecutes a SQL query | ||
:<query> - SQL query to execute | :<query> - SQL query to execute | ||
;Returns: | |||
:*"0" Success, "1" Failure | |||
:*A message string | |||
=== SQL_ExecuteScript === | |||
<highlight-nsis>MSSQL_OLEDB::SQL_ExecuteScript <scriptfile></highlight-nsis> | |||
;Excecutes a SQL query contained in a file | |||
:<scriptfile> - Path to file containing the script to execute (max 60000 bytes) | |||
;Returns: | ;Returns: | ||
Line 83: | Line 95: | ||
DetailPrint $0 | DetailPrint $0 | ||
MSSQL_OLEDB::SQL_Execute /NOUNLOAD "$SQLQUERY" | MSSQL_OLEDB::SQL_Execute /NOUNLOAD "$SQLQUERY" | ||
Pop $0 | |||
DetailPrint $0 | |||
Pop $0 | |||
DetailPrint $0 | |||
MSSQL_OLEDB::SQL_GetError /NOUNLOAD | |||
Pop $0 | |||
DetailPrint $0 | |||
Pop $0 | |||
DetailPrint $0 | |||
MSSQL_OLEDB::SQL_GetRow /NOUNLOAD | |||
Pop $0 | |||
DetailPrint $0 | |||
Pop $0 | |||
DetailPrint $0 | |||
MSSQL_OLEDB::SQL_GetRow /NOUNLOAD | |||
Pop $0 | |||
DetailPrint $0 | |||
Pop $0 | |||
DetailPrint $0 | |||
MSSQL_OLEDB::SQL_GetError /NOUNLOAD | |||
Pop $0 | |||
DetailPrint $0 | |||
Pop $0 | |||
DetailPrint $0 | |||
setoutpath $PLUGINSDIR | |||
FILE test.sql | |||
MSSQL_OLEDB::SQL_ExecuteScript /NOUNLOAD "$PLUGINSDIR\test.sql" | |||
Pop $0 | Pop $0 | ||
DetailPrint $0 | DetailPrint $0 |
Revision as of 11:35, 29 March 2007
Author: sgiusto@mmpoint.it (talk, contrib) |
Download
MSSQL OLEDB.zip (73 KB)
Description
The MSSQL OLEDB plugin for NSIS provides some functions to add MSSQL interoperability within an install script
Version: 1.0 12th March 2007. First Release
Version: 1.1 20th March 2007. Fixed bug in DllMain under Windows 2000
Version: 1.2 29th March 2007. Added SQL_ExecuteScript function
Supported on: Windows NT, Windows 2000, Windows XP.
Notes
All functions must be called with the /NOUNLOAD switch Only SQL_Logout must be called as last and without /NOUNLOAD
Functions
SQL_Logon
MSSQL_OLEDB::SQL_Logon <server> <user> <password>
- Logs on a SQL Server
- <server> - Network name of SQL Server to log on
- <user> - User (leave blank to use windows authentication)
- <password> - Password
- Returns
-
- "0" Success, "1" Failure
- A Message string
SQL_Execute
MSSQL_OLEDB::SQL_Execute <query>
- Excecutes a SQL query
- <query> - SQL query to execute
- Returns
-
- "0" Success, "1" Failure
- A message string
SQL_ExecuteScript
MSSQL_OLEDB::SQL_ExecuteScript <scriptfile>
- Excecutes a SQL query contained in a file
- <scriptfile> - Path to file containing the script to execute (max 60000 bytes)
- Returns
-
- "0" Success, "1" Failure
- A message string
SQL_GetRow
MSSQL_OLEDB::SQL_GetRow
- Retrieves a row of data from the SQL server
- Returns
-
- "0" Success, "1" Failure, "2" No more data to read
- A string containing the row of data (each column is separated by a '|' char). A message in case if error or no more data
SQL_GetError
MSSQL_OLEDB::SQL_GetError
- Retrieves last error message generated by SQL Server. Call this function after a failure to get SQL state, native error code and message
- Returns
-
- "0" Success
- A string containing the error
SQL_Logout
MSSQL_OLEDB::SQL_Logout
- Deallocates memory used by dll and logs out of SQL server. Use this function WITHOUT the /NOUNLOAD switch when finished using the plugin
Usage Example
detailprint "Loggin on to SQL server $SQLSERVER" MSSQL_OLEDB::SQL_Logon /NOUNLOAD "$SQLSERVER" "$SQLUSER" "$SQLPASSWORD" pop $0 detailprint $0 pop $0 detailprint $0 MSSQL_OLEDB::SQL_GetError /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_Execute /NOUNLOAD "$SQLQUERY" Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_GetError /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_GetRow /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_GetRow /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_GetError /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 setoutpath $PLUGINSDIR FILE test.sql MSSQL_OLEDB::SQL_ExecuteScript /NOUNLOAD "$PLUGINSDIR\test.sql" Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_GetError /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_GetRow /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_GetRow /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_GetError /NOUNLOAD Pop $0 DetailPrint $0 Pop $0 DetailPrint $0 MSSQL_OLEDB::SQL_Logout
Credits
Written by Stefano Giusto [sgiusto@mmpoint.it]