TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mark Fenech
NA
82
68.9k
Populate Listbox from database
Jun 20 2011 4:13 PM
Hi i have a combobox and i need to populate it with the name of the publisher. From the table i have 2 columns id and name. What am I doing wrong ?
public void populateComboBox(ComboBox cmb)
{
cmd = new SqlCommand("SELECT Name FROM tbl_publisher", sqlConn);
ds = new DataSet();
da = new SqlDataAdapter(cmd);
SqlCommandBuilder sqb = new SqlCommandBuilder(da);
da.Fill(ds, "tbl_publisher");
foreach (DataRow myRow in ds.Tables["tbl_publisher"].Rows)
{
//string publish = (string)myRow["Name"];
cmb.Items.Add(ds.Tables["tbl_publisher"].Rows[0]["Name"].ToString());
}
}
Reply
Answers (
2
)
SNMP Printing
about datagridview columns header width