Showing posts with label Quickbooks. Show all posts
Showing posts with label Quickbooks. Show all posts

20100129

Processing QBXML In SQL Server

I've been working with QuickBooks again, and this time I need to parse some QBXML in the database so I can do some data syncronization on a schedule.

SQL Server 2005+ has some nice XML tools that make things a lot easier.  I was having trouble getting things to show up, but eventually found some pretty basic examples.

I'm parsing an Invoice Query response.

Here is what I came up with:
-- variable to hold document reference
DECLARE @docHandle int

-- variable to hold actual XML
DECLARE @xmlDocument nvarchar(max) -- or xml type

-- Fill XML variable
SELECT TOP 1 @xmlDocument = QBXML FROM QBBridge ORDER BY QBBridgeID DESC

-- Use built in Procedure to process the XML into Data
EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument;

    DECLARE @ParentID int
    DECLARE qbXMLCursor CURSOR FOR
        -- Get All InvoiceRet Objects.
        SELECT ID FROM OPENXML(@docHandle, N'/QBXML/QBXMLMsgsRs') WHERE NodeType = 1 AND LocalName = 'InvoiceRet'

    -- cycle through InvoiceRets and compile Sub Data.
    OPEN qbXMLCursor
    FETCH NEXT FROM qbXMLCursor INTO @ParentID

   
    WHILE @@FETCH_STATUS = 0
    BEGIN

        -- Use Common Table Expression to compile values to names of parent nodes
        -- I named my table columns <ParentName>.<ParentName>.<Name> so I'm sitting pretty for an insert from this.
        WITH InvoiceValues ([LocalName], [Value], [Level], [ID]) AS
        (
            SELECT    LocalName,
                    [text],
                    1 AS [Level],
                    [ID]
            FROM    OPENXML(@docHandle, N'/QBXML/QBXMLMsgsRs')
            WHERE ParentID = @ParentID
            UNION ALL
            SELECT    CASE WHEN SubValues.LocalName = '#text' THEN
                        InvoiceValues.LocalName
                    ELSE
                     InvoiceValues.LocalName + '.' + SubValues.LocalName
                     END As LocalName,
                    [text],
                    InvoiceValues.[Level] + 1 AS [Level],
                    SubValues.[ID]
            FROM    InvoiceValues
                    INNER JOIN OPENXML(@docHandle, N'/QBXML/QBXMLMsgsRs') As SubValues
                    ON InvoiceValues.ID = SubValues.ParentID
        )
        SELECT    [LocalName], [Value]
        FROM    InvoiceValues
        WHERE Value IS NOT NULL
           
        FETCH NEXT FROM qbXMLCursor INTO @ParentID
    END
    CLOSE qbXMLCursor
    DEALLOCATE qbXMLCursor

EXEC sp_xml_removedocument @docHandle


20091109

RE: Quickbooks QBFC 80040154 "Co-Create error"?

Previously I had problems getting a desktop application to integrate with QuickBooks on a 64 bit Windows Server 2008 operating system running IIS 7.0.  Recently I've moved my development Website to the same 64 bit machine, and I was experience same problems with getting my .Net website to be able to use the QuickBooks QBFC8 Library.  Thanks to some experience from before I knew I should see if this was a problem going from 32 Bit to 64 Bit.  It was.  I had to "Enable 32-bit Applications" in the Advanced Settings on the Application Pool.

20091016

Quickbooks QBFC 80040154 "Co-Create error"?

Today I got "Retrieving the COM class factory for component with CLSID {EE7620FE-2EE1-4077-8A52-E485E85DD6B1} failed due to the following error: 80040154." Found out it was because I was including multiple instances (different versions) of the same class (QBFC4,6,8) so excluded the old dlls and everything worked.

QuuuiiiicckkkBoooocckkkkssss!

Every time I try to have my integrated application try to open QuickBooks in "Unattended" mode it tells me my Internet Explorer Security Settings are too high for it to work properly.  So I try adding the address to the Trusted Sites list, and then IE says that the address is not in a proper format.  Note to Intuit, if you're going to require this stupid help file to come up, don't make it required, you know, since it's NOT necessary.  Also, please don't let it break integrated applications.  So annoying.

20091015

QuickBooks SDK 8.0, QBFC8 and Windows Server 64 Bit

Was having problems with QB SDK 8.0 not working properly, discovered via intuit developer forum that I needed to force x86 compilation instead of "Any CPU".  Was getting an error similar to "Could not find the COM Class with CLSID *****-******....".  Switched the compilation method to x86 explicitly, and it started working.  Yay!