15
Answers

how to fill data in comboBox. but error was found?

vinod jangir

vinod jangir

9y
573
1
try
{
string connString = @"Data Source=VINODKUMAR;Initial Catalog=ShreeSankalp;Persist Security Info=True;User ID=sa;Password=1234567890";
using (SqlConnection sqlConn = new SqlConnection(connString))
{
string sqlQuery = @"SELECT Batch No * from New Batchs";
SqlCommand cmd = new SqlCommand(sqlQuery, sqlConn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
//dt.Columns.Add("Batch No", typeof (string));
comboBox1.DisplayMember = "Batch No";
comboBox1.DataSource = dt;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
MessageBox.Show("Please Enter Admission ID");
}
Answers (15)