MagentoCommandBuilder Class
Automatically generates single-table commands used to reconcile changes made to a
System.Data.DataSet with the Magento.
The following example uses
MagentoCommand, along with
MagentoDataAdapter and
MagentoConnection, to select rows from Magento. The example is passed an initialized
System.Data.DataSet, a connection string, a query string that is SQL SELECT statement, and a string that is the name of the Magento table. The example then creates a
MagentoCommandBuilder.
public DataSet SelectMagentoSrvRows(DataSet myDataSet,string magentoConnection,string mySelectQuery,string myTableName)
{
MagentoConnection myConn = new MagentoConnection(magentoConnection);
MagentoDataAdapter myDataAdapter = new MagentoDataAdapter();
myDataAdapter.SelectCommand = new MagentoCommand(mySelectQuery, myConn);
MagentoCommandBuilder magentoCommandBuilder = new MagentoCommandBuilder(myDataAdapter);
myConn.Open();
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "Departments");
//code to modify data in dataset here
//Without the MagentoCommandBuilder this line would fail
myDataAdapter.Update(myDataSet, "Departments");
myConn.Close();
return myDataSet;
}
Public Function SelectMagentoSrvRows(myDataSet As DataSet, magentoConnection As String, mySelectQuery As String, myTableName As String) As DataSet
Dim myConn As New MagentoConnection(magentoConnection)
Dim myDataAdapter As New MagentoDataAdapter()
myDataAdapter.SelectCommand = New MagentoCommand(mySelectQuery, myConn)
Dim magentoCommandBuilder As MagentoCommandBuilder = New MagentoCommandBuilder(myDataAdapter)
myConn.Open()
Dim myDataSet As DataSet = New DataSet
myDataAdapter.Fill(myDataSet, "Departments")
' Code to modify data in DataSet here
' Without the MagentoCommandBuilder this line would fail.
myDataAdapter.Update(myDataSet, "Departments")
myConn.Close()
SelectMagentoSrvRows = myDataSet
End Function
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2