In This Topic
QuickBooksLoader component is used for bulk uploading a large number of records to QuickBooks Online.
To start uploading data, create a QuickBooksLoader component. Then you may tweak its BatchSize property. BatchSize property determines a maximal number of records in a batch. After this you need to specify columns to load data. You may do it either manually, using the Columns property, or you may use the CreateColumns method to retrieve table columns information from the table specified in the TableName property. Then call the Open method and use the SetValue method to set values for the row fields. To switch to the next row, call the NextRow method.
After you have finished loading data, call the Close method. This mthod sends the last batch to the server.
The following example demonstrates using the QuickBooksLoader class.
using (var connection = new QuickBooksConnection("Company Id=1234567890;Access " +
"Token=asdqerTYUJcom5DSKL0djSSBEEFcJohjCGXixTTOM4Z8UpiX;Access Token " +
"Secret=ojVArHdmHagedPRIIVtP8DCQNUbGkloK7Rgct59x;Consumer " +
"Key=vbnrdKcCHaccybn1fbwje3UJLOJm1e;Consumer Secret=649QYsbe76LfeFbhajG6ccaeG8pobxbkiL1De0DS;")) {
connection.Open();
var loader = new QuickBooksLoader("Customer", connection);
loader.Columns.Add("Title", DbType.String, 0, 0, 0);
loader.Columns.Add("DisplayName", DbType.String, 0, 0, 0);
try {
loader.Open();
for (int i = 1; i <= 10; i++) {
loader.SetValue("Title", "Test " + i);
loader.SetValue("DisplayName", "Test " + i);
loader.NextRow();
}
loader.Close();
}
catch (QuickBooksException ex) {
// process exception
}
}
Using connection As New QuickBooksConnectionCompany Id=1234567890;Access " & _
"Token=asdqerTYUJcom5DSKL0djSSBEEFcJohjCGXixTTOM4Z8UpiX;Access Token " & _
"Secret=ojVArHdmHagedPRIIVtP8DCQNUbGkloK7Rgct59x;Consumer " & _
"Key=vbnrdKcCHaccybn1fbwje3UJLOJm1e;Consumer Secret=649QYsbe76LfeFbhajG6ccaeG8pobxbkiL1De0DS;")
connection.Open()
Dim loader As New QuickBooksLoader("Customer", connection)
loader.Columns.Add("Title", DbType.String, 0, 0, 0)
loader.Columns.Add("DisplayName", DbType.String, 0, 0, 0)
Try
loader.Open()
For i As Integer = 1 To 10
loader.SetValue("Title", "Test " & i)
loader.SetValue("DisplayName", "Test " & i)
loader.NextRow()
Next
loader.Close()
Catch ex As QuickBooksException
'process exception
End Try
End Using
After calling the Close method you can retrieve the results of data loading operation as an array of structs with the GetResults method.