Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete(object[] primaryKeyValues) example please
Message
From
09/05/2004 06:31:37
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Delete(object[] primaryKeyValues) example please
Miscellaneous
Thread ID:
00902261
Message ID:
00902261
Views:
42
I guessed from the documentation that I could pass in an array of primary key values or multiple records to delete.

"Deletes the record with the specified primary key values in the default table"
Ah. RECORD. Singular. Key VALUES. Plural. Oops. My code:

// alst_UpdateIDs: arraylist of ids changed/deleted in datagrid
// there is NO DataSet
object[] ids;
ids = alst_UpdateIDs.ToArray();
oCompany.Delete(ids);

One value, 543, passed in array, and every record in my table was deleted. Oops.

traced to:
OakLeaf.MM.Main.Business.mmBusinessObject.Delete(object[] primaryKeyValues, string tableName)

when ds == null, command became "DELETE FROM Company WHERE 543 = @543" and the parameter @543 value is set to ... 543. Oops.

I read the code NOW as handling tables with multiple column primary keys. But I'm still confused as to how create an array where
foreach (object PK in primaryKeyValues)
PK becomes a string with the primary key name and
primaryKeyValues[ParamCount]
becomes a value.

I believe there's a bug building the query when there's no dataset.
Perhaps the foreach statement should read:
foreach(string PK in this.PrimaryKeys)...

Please consider enhancing the documentation in \MMNetDevGuide1.1.chm::/_0Y80ZS806.htm, "Deleting Data using Business Objects" for this method, re: passing values in an array with the corresponding order of primary key columns in this.PrimaryKeys[]

Thanks!
Next
Reply
Map
View

Click here to load this message in the networking platform