QuickBooks SDK QBFC VB.NET Get SalesOrder

This is a quick and dirty explanation for getting a sales order out of QuickBooks Pro 2013 419231 (Google Affiliate Ad).

You will need to add the QBFC library.  Generally located here...

It is easier to manage iterating through the response as XML vs. using the QBFC Response message (which also loads its own XML Dom and is slow) because of the native XML/xpath .NET libraries.

Note:  You will to have the client open the first time you run and change the below line...
sessionManager.BeginSession("\\server\sharename\Test Company.qbw", QBFC12Lib.ENOpenMode.omDontCare)
to sessionManager.BeginSession("", QBFC12Lib.ENOpenMode.omDontCare)
...so that it opens the database QuickBooks currently has open.  This is so that you can authorize the application for access.  You can then point it across the network as you need to without having the desktop app open.

Sample Code:

Sub Main()
End Sub

Private Sub GetSalesOrders() as String
Dim sessionManager As New QBFC12Lib.QBSessionManager
Dim request As QBFC12Lib.IMsgSetRequest
Dim response As QBFC12Lib.IMsgSetResponse
Dim tmpResponse As String
request = sessionManager.CreateMsgSetRequest("US", 12, 0)
Dim SalesOrderQuery As QBFC12Lib.ISalesOrderQuery
SalesOrderQuery = request.AppendSalesOrderQueryRq()

'Build query.
'Gets order ids between #1 and #2.  Change as needed.
'Connect to QuickBooks and begin a session
sessionManager.OpenConnection("", "Sample VB.NET Code Accessing SalesOrder")
sessionManager.BeginSession("\\server\sharename\Test Company.qbw", QBFC12Lib.ENOpenMode.omDontCare)

response = sessionManager.DoRequests(request)
tmpResponse = response.ToXMLString()
Catch ex As Exception
End Try

return response.ToXMLString
End Sub

    Public Sub EndSessionCloseConnection(ByRef Session As QBFC12Lib.QBSessionManager)
        On Error GoTo Errs
        'If booSessionBegun Then
        'End If
        Exit Sub
        MsgBox("HRESULT = " & Err.Number & " (" & Hex(Err.Number) & ") " & vbCrLf & vbCrLf & Err.Description, _
                    MsgBoxStyle.Critical, _
                    "Error in EndSessionCloseConnection")
    End Sub

You need to sign up for a developer account at QuickBooks website in order to access the QBFC api.
QBFC api link
Visual Studio 2012 Professional
QuickBooks 2013
QuickBooks Pro 2013 419231 (Google Affiliate Ad)
Used Books delivered from Georgia