how to add rows in DataRow object and How to Merge it to Dataset Object
-
Hello All Plz help me I am new to C#.net and i need to Merge the row to Dataset object I am created code as bellow string name = (GridView1.SelectedRow.Cells[1].Text); int id1 = this.getDetails1(name); :rose: DataRow dw // OleDbConnection myconnection = new OleDbConnection(); myconnection = databaseconnection.getconnection(); string str = "select c_TaxShortName ,c_ItemTaxSchemeDetId from t_Item_Tax_SchemeDetail where (c_ItemTaxSchemeDetIdForFrom= " + id1 + ") and (c_SoftDelete = '1') "; OleDbDataAdapter adpt = new OleDbDataAdapter(str, myconnection); ds = new DataSet(); adpt.Fill(ds); // fill OleDbDataAdapter Object with selected record :rose: ds.Merge(dw); ddl_FieldDef. DataSource = ds; ddl_FieldDef.DataTextField = "c_TaxShortName"; ddl_FieldDef.DataValueField = "c_ItemTaxSchemeDetId"; ddl_FieldDef.DataBind(); // bind data myconnection.Close(); // Close connection I need to add row in DataRow object like ;-> "PP","DP" "MRP"
-
Hello All Plz help me I am new to C#.net and i need to Merge the row to Dataset object I am created code as bellow string name = (GridView1.SelectedRow.Cells[1].Text); int id1 = this.getDetails1(name); :rose: DataRow dw // OleDbConnection myconnection = new OleDbConnection(); myconnection = databaseconnection.getconnection(); string str = "select c_TaxShortName ,c_ItemTaxSchemeDetId from t_Item_Tax_SchemeDetail where (c_ItemTaxSchemeDetIdForFrom= " + id1 + ") and (c_SoftDelete = '1') "; OleDbDataAdapter adpt = new OleDbDataAdapter(str, myconnection); ds = new DataSet(); adpt.Fill(ds); // fill OleDbDataAdapter Object with selected record :rose: ds.Merge(dw); ddl_FieldDef. DataSource = ds; ddl_FieldDef.DataTextField = "c_TaxShortName"; ddl_FieldDef.DataValueField = "c_ItemTaxSchemeDetId"; ddl_FieldDef.DataBind(); // bind data myconnection.Close(); // Close connection I need to add row in DataRow object like ;-> "PP","DP" "MRP"
You really can't merge a datarow and a dataset, they're a level of abstraction away from each other. If you're looking to add a row to a table within a dataset, you can use ds.Tables["tablename"].Rows.Add(DataRow), assuming they have the same schema.