How do I fill an MRU list?


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I have dropped a DevEx MRUEdit control onto a form for the first time.  Cool little control.  I want to fill this thing with a distinct list of part descriptions.  Here is my working code for your review:

private void FillPartDescriptionMRU()
{
   
// get the distinct list of part descriptions
   
SqlConnection cn = new SqlConnection(MicroFour.StrataFrame.Data.DataLayer.DataSources["Aspire"].ConnectionString);
   
SqlCommand cmd = new SqlCommand();
    cmd.Connection = cn;
    cmd.CommandType =
CommandType.Text;
   
ADUserBO mADUser = new ADUserBO();
   
SqlParameter pDiv = new SqlParameter("@division", mADUser.LocationIndex);
    cmd.Parameters.Add(pDiv);
    cmd.CommandText =
"SELECT DISTINCT partdesc FROM PartsMaster WHERE (divisionindex = @division) AND (inactive = 0) ORDER BY partdesc";
   
SqlDataAdapter sda = new SqlDataAdapter(cmd);
   
DataSet ds = new DataSet();
    sda.Fill(ds);
   
foreach (DataRow dr in ds.Tables[0].Rows)
    {
        txtPartDesc.Properties.Items.Add((
string)dr[0]);
    }
}

Is this the best way to approach a distinct list of strings from my database in order to fill my MRU list?  I do have a PartsBO...is there a way to get these strings from the BO?  Also, the list is filled in descending alphabetical order, even though I have specified an ASC sort in the query.  Is there a reason why my sort is backwards?

Thanks for any help on this!!
Bill


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Bill Cunnien - 17 Years Ago
Bill Cunnien - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Bill Cunnien - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                         Excellent! That tip just cut my code in half. Lean and mean! :D...
Bill Cunnien - 17 Years Ago
                             Cool :cool:
Trent L. Taylor - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search