narasiman rao

narasiman rao

  • NA
  • 519
  • 747.2k

in combo box data is not retrieved from the DB in WEB Applic

Aug 13 2015 7:25 AM
 
   my code as follows

SqlConnection conn = new SqlConnection("Data Source=DOCTOR\SQLEXPRESS;Initial Catalog=HIMT_Testing;User ID=sa;Password=himt123");

conn.Open();

SqlCommand sc = new SqlCommand("select Designation from Designations where active <>'d'", conn);

SqlDataReader reader;
reader = sc.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("Designation", typeof(string));
dt.Load(reader);

ComboBox1.DataTextField = "Designation";
ComboBox1.DataValueField = "Designation";

ComboBox1.DataSource = dt;
conn.Close();

in combo box data is not retrieved from the database.

what is the problem in my code. it is web application. 

Answers (1)