Hello
I'm fairly new to c# coming from an access background, what I am trying to do is populate a combo box from a forms load event. Is there a way I can hide the Auto number (pTypeID) and display the text description field (pType) while keeping the pTypeID as the cboPTypes.SelectedItem?
Thanks in advance.
Roy.
cboPTypes.Items.Clear();
//Create Connection
OleDbConnection conn = new OleDbConnection(@"provider=Microsoft.Jet.OLEDB.4.0; data source=c:\dBPhones.mdb");
try
{
//Open Connection
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT p.pTypeID, p.pType FROM tblPhoneTypes AS p ORDER BY p.pType;", conn);
OleDbDataReader myReader;
myReader = cmd.ExecuteReader();
while (myReader.Read())
int phType = (int)myReader["pTypeID"];
string phDesc = (string)myReader["pType"];
cboPTypes.Items.Add(phType + ", " + phDesc);
}
catch
finally
if (conn != null)
conn.Close();