Quantcast
Viewing all articles
Browse latest Browse all 2

How to bind Combobox to a table field?

Binding ComboBox to a table using Stored Procedure

SqlDataAdapter da = new SqlDataAdapter(“StoredProcedureName”,Connection);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add(new SqlParameter(“@Param1″, Value for @Param1));
DataSet ds = new DataSet( );
da.Fill(ds, “TableName”);
dataGridView1.DataSource = ds;
dataGridView1.DataMember = “TableName”;

Binding ComboBox to a table using Command

Connection.Open();

SqlDataAdapter da = new SqlDataAdapter(“select Uname from Table1″, Connection);

DataSet ds = new DataSet( );

da.Fill(ds, “Table1″);
comboBox1.DataSource =ds.Tables[0];
comboBox1.DisplayMember = “Uname”;

Connection1.Close();

Udhaya

PiSquare Soft Solns


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 2

Trending Articles