QuickBooksConnection Class
Represents an open connection to QuickBooks Online.
The following example creates a
QuickBooksCommand and a
QuickBooksConnection. The
QuickBooksConnection is opened and set as the
Connection property. The example then calls
ExecuteNonQuery method, and closes the connection. To accomplish this, the
ExecuteNonQuery is passed a connection string and a query string that is SQL INSERT statement.
|
|---|
public void InsertRow(string quickBooksConnectionString)
{
// If the connection string is empty, use default.
if(quickBooksConnectionString == "")
{
quickBooksConnectionString =
"Company Id=1440905870;Refresh Token=AB11590759756UCO8O6CpRQcAMP00sIANafgS8Y4RN10rpLJNM;Token Server=file://D:\\temp\\QuickBooksToken.txt";
}
QuickBooksConnection myConn = new QuickBooksConnection(quickBooksConnectionString);
string myInsertQuery = "INSERT INTO Customer (DisplayName, Notes) VALUES ('John Smith', 'VIP Customer')";
QuickBooksCommand quickBooksCommand = new QuickBooksCommand(myInsertQuery);
quickBooksCommand.Connection = myConn;
myConn.Open();
try
{
quickBooksCommand.ExecuteNonQuery();
}
finally
{
myConn.Close();
}
} |
|
|---|
Public Sub InsertRow(quickBooksConnectionString As String)
' If the connection string is empty, use default.
If quickBooksConnectionString = "" Then
quickBooksConnectionString = _
"Company Id=1440905870;Refresh Token=AB11590759756UCO8O6CpRQcAMP00sIANafgS8Y4RN10rpLJNM;Token Server=file://D:\\temp\\QuickBooksToken.txt"
End If
Dim myConn As New QuickBooksConnection(quickBooksConnectionString)
Dim myInsertQuery As String = "INSERT INTO Customer (DisplayName, Notes) VALUES ('John Smith', 'VIP Customer')"
Dim quickBooksCommand As New QuickBooksCommand(myInsertQuery)
quickBooksCommand.Connection = myConn
myConn.Open()
Try
quickBooksCommand.ExecuteNonQuery()
Finally
myConn.Close()
End Try
End Sub |