Combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teddy86
    New Member
    • Oct 2007
    • 2

    Combo box

    hi im new to C#...

    following code to get a database SQL table column values and bind it to combo box.....AssetTy pe is the table and AssetTypName is the column to bind to the combo box.....in C# windows application.... .........

    it shows the exception like "child list cannot be created ".......... ..

    [CODE=vbnet]private void FormAsset_Load( object sender, EventArgs e)
    {
    try
    {
    SqlCommand sqlCmd = new SqlCommand();
    sqlCmd.Connecti on = sqlCon;
    sqlCon.Open();
    sqlCmd.CommandT ype = CommandType.Tex t;
    sqlCmd.CommandT ext = "select distinct AssetTypName from AssetType ";
    DataSet ds = new DataSet("AssetT ype");
    SqlDataAdapter da = new SqlDataAdapter( );
    da.SelectComman d = sqlCmd;
    da.Fill(ds);
    cmbAssetType.Da taSource = ds.DefaultViewM anager;
    cmbAssetType.Di splayMember = "AssetTypNa me";
    cmbAssetType.Va lueMember = "AssetType.Asse tTypName";
    int i = sqlCmd.ExecuteN onQuery();
    {
    MessageBox.Show ("success");
    }

    }
    catch (Exception ex)
    {
    MessageBox.Show (ex.ToString()) ;


    }
    }[/CODE]
    Last edited by debasisdas; Oct 18 '07, 06:35 AM. Reason: Formatted using code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET Forum.

    Comment

    Working...