L
Lars E
Hi all
I have a small problem.
I have a datatable with 8 columns. But it is only data in 5 of the columns.
Data for the remaing 3 columns is in another dataset.
I Want to run trough the datatable and fill out the remaining data.
My code so far:
if (this.fetch("custinfo", "fetchCustInfo", out customers, parameters))
{
//Create a datatable for the the combined tables to be view in a
datagridview
DataTable dtCustInfo = new DataTable("CustInfo");
//Fill this datatables with customers.
dtCustInfo = customers.Tables[0];
//Adding field phonenumber. Will get value from custcont later
DataColumn dcPhone = dtCustInfo.Columns.Add("cc-telephone",
typeof(Int32));
dcPhone.AllowDBNull = true;
dcPhone.Unique = false;
//Adding field faxnumber. Will get value from custcont later
DataColumn dcFax = dtCustInfo.Columns.Add("cc-faxnr", typeof(Int32));
dcPhone.AllowDBNull = true;
dcPhone.Unique = false;
//Adding field e-mail. Will get value from custcont later
DataColumn dcEmail = dtCustInfo.Columns.Add("cc-mail", typeof(Int32));
dcPhone.AllowDBNull = true;
dcPhone.Unique = false;
//Run trough the table and populate the new fields
for(int i=0;i< dtCustInfo.Rows.Count;i++)
{
//PROBLEM....I want to find the row in custoerms.Tables[1] with
the primary value in the field c-custno1 in dtCustInfo datatable
DataRow foundRow =
customers.Tables[1].Rows.Find(dtCustInfo.Rows[0]["c-custno1"]);
if (foundRow != null)
{
//modifiy the 3 fields with data fra det dataset
//dtCustInfo.Columns.Add(
}
}
customerDataGridView.DataSource = dtCustInfo;
Please help if you can.
Thank you very much.
Lars E.
I have a small problem.
I have a datatable with 8 columns. But it is only data in 5 of the columns.
Data for the remaing 3 columns is in another dataset.
I Want to run trough the datatable and fill out the remaining data.
My code so far:
if (this.fetch("custinfo", "fetchCustInfo", out customers, parameters))
{
//Create a datatable for the the combined tables to be view in a
datagridview
DataTable dtCustInfo = new DataTable("CustInfo");
//Fill this datatables with customers.
dtCustInfo = customers.Tables[0];
//Adding field phonenumber. Will get value from custcont later
DataColumn dcPhone = dtCustInfo.Columns.Add("cc-telephone",
typeof(Int32));
dcPhone.AllowDBNull = true;
dcPhone.Unique = false;
//Adding field faxnumber. Will get value from custcont later
DataColumn dcFax = dtCustInfo.Columns.Add("cc-faxnr", typeof(Int32));
dcPhone.AllowDBNull = true;
dcPhone.Unique = false;
//Adding field e-mail. Will get value from custcont later
DataColumn dcEmail = dtCustInfo.Columns.Add("cc-mail", typeof(Int32));
dcPhone.AllowDBNull = true;
dcPhone.Unique = false;
//Run trough the table and populate the new fields
for(int i=0;i< dtCustInfo.Rows.Count;i++)
{
//PROBLEM....I want to find the row in custoerms.Tables[1] with
the primary value in the field c-custno1 in dtCustInfo datatable
DataRow foundRow =
customers.Tables[1].Rows.Find(dtCustInfo.Rows[0]["c-custno1"]);
if (foundRow != null)
{
//modifiy the 3 fields with data fra det dataset
//dtCustInfo.Columns.Add(
}
}
customerDataGridView.DataSource = dtCustInfo;
Please help if you can.
Thank you very much.
Lars E.