Code Comments
Programming Forum and web based access to our favorite programming groups.
I'm having some trouble trying to figure out how to accomplish a task.
Right now I have a combobox that a user
can choose a name out of (the name consists of variables First_Name +
Last_Name). Now after the user has made
their selection and clicks accept. I'd like to somehow reference the
primary key in my database for the person with
that First and Last name.
Here is an example of my code -
private void SelectDriver_Load(object sender, EventArgs e)
{
DriverDatabase ObjDDB = new DriverDatabase();
foreach (DataRow myRow in ObjDDB.tableDrivers.Rows)
{
string First_Name = myRow["First_Name"].ToString();
string Last_Name = myRow["Last_Name"].ToString();
this.driverbox.Items.Add(First_Name + Last_Name);
}
ObjDDB = null;
}
That code populates my ComboBox with the information from my database. Now,
when the user clicks on my 'Accept' button
I'd like to be able to reference the record in the database for which he/she
has selected. I could do a query in the database for
the first and last name, according to the output of combobox.text when the
user hits enter but that wouldn't work because first
and last name are not unique. It might find more then one record or even
the wrong record.
I'm fairly new to programming, so any help would be appreciated.
Thanks
- Rob
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.