peterpiper
Member
- Joined
- Nov 6, 2013
- Messages
- 5
- Programming Experience
- Beginner
I picked up the following code from the internet but I am getting errors
I think there is an error on the sqlSelect statement. I am using VS2012
Here is the code
Would appreciate if someone could tell me what is exactly wrong.
The full project code can be found here
synchronizing_master-detail_data_in_a_wi.html
I think there is an error on the sqlSelect statement. I am using VS2012
Here is the code
C#:
protected DataSet LoadData()
{
string sqlConnectString = @
Integrated security=SSPI;Initial Catalog=AdventureWorks;
string sqlSelect =
@
FROM Sales.SalesOrderHeader
WHERE SalesOrderID BETWEEN 43660 AND 43669;
SELECT SalesOrderID, SalesOrderDetailID, OrderQty, ProductID, LineTotal
FROM Sales.SalesOrderDetail
WHERE SalesOrderID BETWEEN 43660 AND 43669;
// Fill and return a DataSet containing sales order header and sales order
// detail DataTable objects that are related on the SalesOrderID field
SqlDataAdapter da = new SqlDataAdapter(sqlSelect, sqlConnectString);
da.TableMappings.Add("Table", "SalesOrderHeader");
da.TableMappings.Add("Table1", "SalesOrderDetail");
DataSet ds = new DataSet();
da.Fill(ds);
// Add a relation between parent and child table.
ds.Relations.Add("FK_SalesOrderDetail_SalesOrderHeader",
ds.Tables["SalesOrderHeader"].Columns["SalesOrderID"],
ds.Tables["SalesOrderDetail"].Columns["SalesOrderID"]);
return ds;
}
Would appreciate if someone could tell me what is exactly wrong.
The full project code can be found here
synchronizing_master-detail_data_in_a_wi.html