Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
I tried several times in combobox data is not retrieved DB
narasiman rao
Aug 13 2015 10:39 PM
496
Reply
My code as follows
In pageload i written the below code as follows
SqlConnection conn = new SqlConnection(@"Data Source=DOCTOR\SQLEXPRESS;Initial Catalog=Testing;User ID=sa;Password=a");
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);
dt.Load(reader);
ComboBox1.DataTextField = "Designation";
ComboBox1.DataValueField = "Designation";
ComboBox1.DataSource = dt;
ComboBox1.DataBind();
conn.Close();
In database records as follows (Table name Designations )
ID Name Designation
1 Raj Course Officer
2 Ramesh Authorised signatoury
In run mode as follows
Designation Combobox
But in combobox designation is not displayed.
i tried several time but in combobox designation is not shown.
please help me what is the problem in my above code.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
.NET
C# winform Desktop application to Track the PHP live Website