Archive: NSis and MSSQL_OLEDB::SQL_ExecuteScript


NSis and MSSQL_OLEDB::SQL_ExecuteScript
I have a bit of a problem the SQL scripts that i use are good,they do what they were coded for when they are directly called in MS SQL, but when i call them in a NSis script they either do not execute or return an error. The Ones calling a delete on certain rows of a table always return an error,the ones calling to drop base do not drop because they say that de DB is in use. Here is the big picture, i call a script to create a temporary DB to retrieve the Data of two existing DB then modify the temporary DB(delete some rows on two tables).After, i drop the two existing DB, recreate them, transfer data in those two DB from the temporary one, drop the temporary one.The data transfering goes well both ways,the big issue is i cannot delete rows from the temporary DB and i cannot drop the two existing DB. I had to seperate alot of queries (like the ones using Identity_Insert on /off) to make them work .
1) Is there some kind of protection that prevents Data from being deleted when called from Nsis?

2)Why Nsis says the DB is in use when i put a 10 second sleep before the last insert to drop a DB?


P.S. Remember i doubled check all My queries and they are working perfectly fine when i call them from MS SQL or Access.


Can you give some sample code you are using?
It should work without a problem.

What version of MSSQL are you running against?


In NSIS


//Insert code that works
MSSQL_OLEDB::SQL_ExecuteScript "InsertIntoMyTable.sql"

Sleep 10000
//Deletion query
MSSQL_OLEDB::SQL_ExecuteScript "ModifyMyTable.sql"
MSSQL_OLEDB::SQL_GetError
//error Message



The Deletion query that works in MS SQL



Delete From MyTable
Where (Id>1 Or Id =1) And (Id>5 or Id=5) And (otherStuffId=5 And OtherStuffId=6)


The Id is a primary key and i want to delete the 2 rows of each Id where otherStuffId=5 and otherStuffId=6

The deletion query return an error message (with NSIS) that's what i do not understand.
I'm workin with Ms SQL express 2005.

First I think nothing will deleted ever with this query, because (otherStuffId=5 And OtherStuffId=6) will always return false...

But about your error, what error code is returned?


You were right about the query but in acces and MSSQL both returned Success.(An "Or" was needed). Plus the fact i'm new to NSIS i used an old Script using execute "sb_attach_db".
It looks like you need to (RMDir ${Installdir}/"SQL") recursivly remove the SQL folder when using the command, but not when you execute a script instead of a query.So that was why the series of scripts were working partly and part time.

Thx!


Hello,
not sure of what are you meaning with 'So that was why the series of scripts were working partly and part time.'
If you have scripts to ececute you should extract them in a convenient folder and then execute them.
Usually you can extract them in the $PLUGINSDIR folder. This is a temp folder that nsis removes after installation.
Look at the example provided with the plugin.
Regards
Stefano