string selectString = "SELECT tCode,tName,tShName,tPrice " + "FROM tTests " + "WHERE dpCode =2"; DataTable dt = new DataTable(); con.Open(); SqlCommand sqlCmd = new SqlCommand(selectString, con); sqlCmd.CommandTimeout = 0; sqlCmd.CommandType = CommandType.Text; sqlCmd.ExecuteNonQuery(); SqlDataAdapter adptr = new SqlDataAdapter(sqlCmd); adptr.Fill(dt); dt.Columns.Add("tCode", typeof(string)); dt.Columns.Add("tName", typeof(string)); dt.Columns.Add("tShName", typeof(string)); dt.Columns.Add("tPrice", typeof(string)); foreach (DataRow myDataRow in dt.Rows) { dt.Rows.Add("tCode = " + myDataRow["tCode"]); dt.Rows.Add("tName = " + myDataRow["tName"]); dt.Rows.Add("tShName = " + myDataRow["tShName"]); dt.Rows.Add("tPrice = " + myDataRow["tPrice"]); } cboTests.DataSource = dt; cboTests.DisplayMember = "tName"; cboTests.ValueMember = "tShName"; cboTests.SelectedIndex = -1; cboTests.Text = ""; con.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)