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]
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]
Comment