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");
}
Raja TPosted Sep 25, 2015, 8:40 AM
{
con.Open();
da = new SqlDataAdapter("select BatchNo from Batches" , con);
dt = new DataTable();
da.Fill(dt);
//DataRow dr;
//dr = dt.NewRow();
//dr.ItemArray = new object[] { 0, "---Select an item---" };
//dt.Rows.InsertAt(dr, 0);
comboBox1.DisplayMember = "BatchNo";
comboBox1.ValueMember = "S.No";
comboBox1.DataSource = dt;
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Which code are tried above code?
vinod jangirPosted Sep 25, 2015, 8:23 AM
Raja TPosted Sep 25, 2015, 8:21 AM
vinod jangirPosted Sep 25, 2015, 8:15 AM
Raja TPosted Sep 24, 2015, 7:20 AM
string sqlQuery = @"SELECT BatchNo from Batches";
SqlCommand cmd = new SqlCommand(sqlQuery, sqlConn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
comboBox1.ValueMember = "BatchNo";
comboBox1.DisplayMember = "BatchNo";
comboBox1.DataSource = ds.Tables[0];
Note : Please check in debug mode data set contains data or not
vinod jangirPosted Sep 24, 2015, 6:43 AM
Manas MohapatraPosted Sep 24, 2015, 6:16 AM
vinod jangirPosted Sep 24, 2015, 6:08 AM
Manas MohapatraPosted Sep 24, 2015, 5:59 AM
vinod jangirPosted Sep 24, 2015, 5:55 AM
Abhishek KumarPosted Sep 24, 2015, 5:22 AM
vinod jangirPosted Sep 24, 2015, 4:51 AM
Manas MohapatraPosted Sep 24, 2015, 3:47 AM
vinod jangirPosted Sep 24, 2015, 3:46 AM
Manas MohapatraPosted Sep 24, 2015, 2:26 AM