public bool UpdateOrders(DSCustOrders inDSCustOrders) { string[] myTableNames = new string[] {inDSCustOrders.Orders.TableName, inDSCustOrders.Order_Details.TableName}; return DALCCommon.Instance.UpdateDataSet(inDSCustOrders, myTableNames, null); }
… for(i=0;i
5
Knowledge
Experience
//Create the update command. mySP = string.Format("{0}Update", inTableName[i]); SqlCommand myUpdateCommand = SqlHelper.CreateCommand(myConnection, mySP, GetSourceColumns(mySP)); myUpdateCommand.Transaction = myTransaction;
Sharing
//Create the delete command. mySP = string.Format("{0}Delete", inTableName[i]); SqlCommand myDeleteCommand = SqlHelper.CreateCommand(myConnection, mySP, GetSourceColumns(mySP)); myDeleteCommand.Transaction = myTransaction; Ty pe
//Update the database with the changes performed to the table (inTableName). //Pass in insert command, delete command, update command, dataset,and table name SqlHelper.UpdateDataset(myInsertCommand, myDeleteCommand, myUpdateCommand, inDS, inTableName[i]);
dD a ta se
}
Ty pe d
D
at as e
t
t
Entity Object
DataView
6
Honorary Methods RowFilter RowStateFilter Sort Find FindRows
2 1-2-3 steps to generate an xml schema for a database table: 1. Create new Item XML Schema to project. 2. Drag table from data source in Server Explorer to XML designer window. 3. Right Click the created connection object and Select “Generate Dataset”. 4. Enable “Show All Files” ... to see the *.cs source.
DataSet Honorary Methods
Type Safe Functional Object Oriented Typed Dataset
GetXml WriteXml AcceptChanges HasChanges GetChanges
Typed Dataset
1
Bind and sort data using the DataView and display using the DataGrid
WS/EM 2005/02
BARONE BUDGE & DOMINICK (PTY) Ltd
DBMS
4
Data Access Block
Client ordersView.RowFilter = string.Format("CustomerID = '{0}'", CustomerList.SelectedValue); ordersGrid.DataSource= ordersView;
DAAB v1 SQL Server 7, 2000, … DAAB v2 SQL Server 7, 2000, … DAAB v3 SQL Server 7, 2000 Oracle OleDb ODBC Enterprise Library v1 SQL Server 7, 2000, … Oracle
Server
Update Dataset, passing CRUD commands to SQLHelper for all tables to be updated within dataset
public DSCustOrders GetOrders() { DSCustOrders myDSOrders = new DSCustOrders(); string[] myTables = new string[] { myDSOrders.Customers.TableName, myDSOrders.Orders.TableName, myDSOrders.Products.TableName, myDSOrders.Order_Details.TableName}; SqlHelper.FillDataset( DALCCommon.Instance.ConnectionString, "GetCustomersAndOrders", myDSOrders, myTables); return myDSOrders; }
3
Access DBMS using Data Access Block v1, v2, v3 Or Enterprise Library – Data Access
Best Practices – Data Access