FreshBooksConnection Class
Represents an open connection to FreshBooks.
The following example creates a
FreshBooksCommand and a
FreshBooksConnection. The
FreshBooksConnection 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 freshbooksConnectionString)
{
// If the connection string is empty, use default.
if(freshbooksConnectionString == "")
{
freshbooksConnectionString =
"API Version=Alpha;Access Token=3d3355b2beea67f9241400fbe28f0b116e3efd2f8a85dda3c35620acdc95cd60;Refresh Token=75836f50da63fc5bf81bb24598511ae131ea422e73d9f321b4c4a44e2dd1c67f;Company Name=Devart";
}
FreshBooksConnection myConn = new FreshBooksConnection(freshbooksConnectionString);
string myInsertQuery = "INSERT INTO Client (Email, FirstName, LastName) VALUES ('smithj@test1.com', 'John', 'Smith')";
FreshBooksCommand freshbooksCommand = new FreshBooksCommand(myInsertQuery);
freshbooksCommand.Connection = myConn;
myConn.Open();
try
{
freshbooksCommand.ExecuteNonQuery();
}
finally
{
myConn.Close();
}
}
Public Sub InsertRow(freshbooksConnectionString As String)
' If the connection string is empty, use default.
If freshbooksConnectionString = "" Then
freshbooksConnectionString = _
"API Version=Alpha;Access Token=3d3355b2beea67f9241400fbe28f0b116e3efd2f8a85dda3c35620acdc95cd60;Refresh Token=75836f50da63fc5bf81bb24598511ae131ea422e73d9f321b4c4a44e2dd1c67f;Company Name=Devart"
End If
Dim myConn As New FreshBooksConnection(freshbooksConnectionString)
Dim myInsertQuery As String = "INSERT INTO Client (Email, FirstName, LastName) VALUES ('smithj@test1.com', 'John', 'Smith')"
Dim freshbooksCommand As New FreshBooksCommand(myInsertQuery)
freshbooksCommand.Connection = myConn
myConn.Open()
Try
freshbooksCommand.ExecuteNonQuery()
Finally
myConn.Close()
End Try
End Sub