Old 11th September 2010, 21:07   #1
Grennvicted
Junior Member
 
Join Date: Sep 2010
Posts: 8
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.

Last edited by Grennvicted; 11th September 2010 at 21:20. Reason: Identation
Grennvicted is offline   Reply With Quote
Old 11th September 2010, 23:34   #2
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
Can you give some sample code you are using?
It should work without a problem.

What version of MSSQL are you running against?
jpderuiter is offline   Reply With Quote
Old 12th September 2010, 00:51   #3
Grennvicted
Junior Member
 
Join Date: Sep 2010
Posts: 8
In NSIS

code:

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


code:

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.
Grennvicted is offline   Reply With Quote
Old 13th September 2010, 00:04   #4
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
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?
jpderuiter is offline   Reply With Quote
Old 16th September 2010, 15:32   #5
Grennvicted
Junior Member
 
Join Date: Sep 2010
Posts: 8
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!
Grennvicted is offline   Reply With Quote
Old 16th September 2010, 16:30   #6
sgiusto
Member
 
Join Date: Mar 2007
Location: Italy
Posts: 99
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
sgiusto 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