Hi,
I am using C# in VS2008 to access an MSI and delete some rows. I am
using the latest weekly WIX build, 3.5.0626. When I try to use the
View.Delete method I receive the InstallerException "Cursor in invalid
state". I've simplified the code and replicated the error with the
sample below:
string strMsiPath = @"C:\Test.msi";
using (Database objDatabase = new Database(strMsiPath,
DatabaseOpenMode.Transact))
{
using (View vwTable = objDatabase.OpenView("SELECT *
FROM Class"))
{
vwTable.Execute();
Record rcdTable = vwTable.Fetch();
while (rcdTable != null)
{
vwTable.Delete(rcdTable);
rcdTable = vwTable.Fetch();
}
}
}
System.Windows.Forms.MessageBox.Show("Done");
I am pretty sure that I am following all of the pointers in the
documentation ("The Record must have been obtained by calling Fetch().
Fails if the row has been deleted. Works only with read-write records.
This method cannot be used with a View containing joins."). There is
also a reference to See Modify(ViewModifyMode, Record) for more remarks.
I've tried replacing vwTable.Delete(rcdTable) with
vwTable.Modify(ViewModifyMode.Delete, rcdTable) and get the same error,
though that's to be expected as View.Delete(Record) just falls through
to View.Modify(Delete,Record).
The equivalent code in VBS works fine:
Const msiOpenDatabaseModeTransact = 1
Const msiViewModifyDelete = 6
Set objWI = Wscript.CreateObject("WindowsInstaller.Installer")
Set objDB = objWI.OpenDatabase("C:\Test.msi",
msiOpenDatabaseModeTransact)
Set objView = objDB.OpenView("SELECT * FROM Class")
objView.Execute
Set objRecord = objView.Fetch
While Not objRecord Is Nothing
objView.Modify msiViewModifyDelete, objRecord
Set objRecord = objView.Fetch
Wend
objView.Close
Set objWI = Nothing
MsgBox "Done"
Any clue as to what I am doing wrong?
Many thanks,
James
This e-mail is confidential and the information contained in it may be
privileged. It should not be read, copied or used by anyone other than the
intended recipient. If you have received it in error, please contact the sender
immediately by telephoning (+44 (0)20 7623 8000) or by return email, and delete
the e-mail and do not disclose its contents to any person. We believe, but do
not warrant, that this e-mail and any attachments are virus free, but you must
take full responsibility for virus checking. Please refer to
http://www.dresdnerkleinwort.com/disc/email/ and read our e-mail disclaimer
statement and monitoring policy.
Dresdner Kleinwort is a brand and trading name of the Commerzbank group and
operates through Commerzbank AG, Dresdner Kleinwort Limited and their affiliated
or associated companies. Commerzbank AG is a company incorporated in Germany
with limited liability and registered in England (registered no. FC008139, place
of business 60 Gracechurch Street, London EC3V 0HR) and is authorised by
Bundesanstalt fuer Finanzdienstleistungsaufsicht (BaFin) and authorised and
subject to limited regulation by the Financial Services Authority (FSA).
Dresdner Kleinwort Limited is a company incorporated in England with limited
liability (registered no. 551334, registered office 30 Gresham Street, London
EC2V 7PG) and is authorised and regulated by the FSA. Details about the extent
of our authorisations and regulation are available on request.
------------------------------------------------------------------------------
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users