When I try to databind my comboBox (specifically field "emplcode") to a
filled dataset , the contents of the comboBox displays a bunch of
"System.Data.Da taRowView". I assume the amount of times
"System.Data.Da taR..." is displayed inside the combobox is the amount of
records in the dataset. On the other hand, if my query is "select emplcode
from payemployee", the databind will work fine (but I don't want to limit
the dataset to one field). Any help is appreciated. This is the code:
DataSet DS_Employees = new DataSet();
SqlConnection SQLConn = new SqlConnection(" Data Source=localhos t; Integrated
Security=SSPI;" +
"Initial Catalog=payroll ");
string strThisQuery = "select * from payemployee"; //If the query were
"select emplcode from payemployee" it works
SqlDataAdapter DA_empl = new SqlDataAdapter (strThisQuery, SQLConn);
DA_empl.Fill(DS _Employees, "payemploye e"); //Do I need the 2nd parameter?
SQLConn.Close() ;
comboBox_emplco de.DataSource = DS_Employees.Ta bles["payemploye e"];
comboBox_emplco de.DisplayMembe r = "emplcode"; //I also tried
comboBox_emplco de.DisplayMembe r = "payemployee.em plcode";
Thanks again,
Omar
filled dataset , the contents of the comboBox displays a bunch of
"System.Data.Da taRowView". I assume the amount of times
"System.Data.Da taR..." is displayed inside the combobox is the amount of
records in the dataset. On the other hand, if my query is "select emplcode
from payemployee", the databind will work fine (but I don't want to limit
the dataset to one field). Any help is appreciated. This is the code:
DataSet DS_Employees = new DataSet();
SqlConnection SQLConn = new SqlConnection(" Data Source=localhos t; Integrated
Security=SSPI;" +
"Initial Catalog=payroll ");
string strThisQuery = "select * from payemployee"; //If the query were
"select emplcode from payemployee" it works
SqlDataAdapter DA_empl = new SqlDataAdapter (strThisQuery, SQLConn);
DA_empl.Fill(DS _Employees, "payemploye e"); //Do I need the 2nd parameter?
SQLConn.Close() ;
comboBox_emplco de.DataSource = DS_Employees.Ta bles["payemploye e"];
comboBox_emplco de.DisplayMembe r = "emplcode"; //I also tried
comboBox_emplco de.DisplayMembe r = "payemployee.em plcode";
Thanks again,
Omar
Comment