2005.09.06 10:17 PM

FlexWiki Notes - SimpleUserDataProvider Bug #2

Okay, there's another problem with the SimpleUserDataProvider class.

To create a new user in its DataSet, the AddUser() method first enumerates the existing DataSet rows to find the highest user Id (maxID). Once it finds the highest Id value, it should add 1 to it before assigning it to the new user row. Unfortunately, it doesn't.

It does this:

DataRow row;
for(int x=0;x<dataSet.Tables["Users"].Rows.Count;x++)
{
    row = dataSet.Tables["Users"].Rows[x];
    if (maxID<(int)row["UserID"])
    {
        maxID=(int)row["UserID"];
    }
}
if (maxID==0)
{
    maxID=1;
}
// Add the user to the DataSet
row = dataSet.Tables["Users"].NewRow();
row["UserEmail"] = email;
row["UserPassword"] = password;
row["UserName"] = name;
row["UserID"] = maxID;
dataSet.Tables["Users"].Rows.Add(row);

It should really do this:

DataRow row;
for(int x=0;x<dataSet.Tables["Users"].Rows.Count;x++)
{
    row = dataSet.Tables["Users"].Rows[x];
    if (maxID<(int)row["UserID"])
    {
        maxID=(int)row["UserID"];
    }
}
// Add the user to the DataSet
row = dataSet.Tables["Users"].NewRow();
row["UserEmail"] = email;
row["UserPassword"] = password;
row["UserName"] = name;
row["UserID"] = maxID + 1;
dataSet.Tables["Users"].Rows.Add(row);


Comments



Post a Comment

 
  (optional)
  (no html)
 
   


TrackBack

TrackBack URL:  http://www.typepad.com/services/trackback/6a00d8341c7bd453ef00d83458460869e2

Listed below are links to weblogs that reference FlexWiki Notes - SimpleUserDataProvider Bug #2:

» Gif plugin for Cropper from Brian Scott
Eric has written a nice gif output plug-in for Cropper. [Read More]

Tracked on Sep 14, 2005 2:36:26 AM