How do I change Quantity for an Inventory Item in Quickbooks using vb.net?

Changing Quantity on hand inside of Quickbooks is tricky.  Quickbooks cannot simply allow you to modify the quantity and keep accounting records of all transactions.  All transactions must be accounted for because there has to be a record of the transaction for tax and valuation of Inventory.

It doesn't matter how we arrive at this situation...it has just happened.

An Item Inventory Adjustment must be made.  You have two options.  You can do this through the QBFC/qbXML and .NET option or if you purchased QuickBooks 2013 Enterprise you can use the QODBC option.  QBFC is pretty well documented so you can leave a comment if you need links.  Otherwise we are going to focus on the QODBC option for now.

Simple sample code in vb.net:

Dim tmpString As String
Dim tmpCommand As New Odbc.OdbcCommand
Dim tmpConnection As New Odbc.OdbcConnection("DRIVER={QODBC Driver for QuickBooks};DFQ=\\Servername\directory1\SubDirectory 2\QuickBooks\My Test Company.qbw;SERVER=SERVERNAME;UseDCOM=Y;OpenMode=F;")
Dim SkuNumber as String = "9780306813542"
Try
   
        tmpString = "INSERT INTO " & Chr(34) & "InventoryAdjustmentLine" & _
        Chr(34) & "(" & _
        Chr(34) & "AccountRefFullName" & Chr(34) & "," & Chr(34) & _
        "TxnDate" & Chr(34) & _
        "," & Chr(34) & "Memo" & Chr(34) & "," & Chr(34) & _
        "InventoryAdjustmentLineItemRefFullName" & Chr(34) & "," & Chr(34) & _
        "InventoryAdjustmentLineQuantityAdjustmentNewQuantity" & Chr(34) & _
        "," & Chr(34) & "FQSaveToCache" & Chr(34) & _
        ") VALUES ('Opening Balance Equity', {d'2012-10-10'}, 'Qty Adj 172', ' & _
        SkuNumber & ', 172, 0)"
        tmpCommand.CommandText = tmpString
        tmpCommand.Connection = tmpConnection
        tmpCommand.Connection.Open()
            tmpCommand.ExecuteNonQuery()
Catch ex As Exception
            tmpString = ex.InnerException.ToString
Finally
            tmpCommand.Connection.Close()
End Try
tmpCommand.Connection = Nothing
tmpCommand = Nothing

This is obviously code for DEBUGGING.  If you think think this is "Copy & Paste" -> Production then you should probably hire a consultant to do this work for you.  The above code was written against QuickBooks 2013 Enterprise using the READ/WRITE version of the QODBC driver.  This is NOT the driver that come packaged with QuickBooks 2013 Enterprise.  That version is READ ONLY.  You can download a trial of the READ/WRITE driver here.