Troubleshooting - QRemote does not consider FQSaveToCache when working with OdbcCommand & Parameters
Problem Description:
QRemote does not consider FQSaveToCache when working with OdbcCommand & Parameters.
I have an application that creates Sales Orders. This is what I execute for each line item:
Running this code against QODBC DSN works well if everything is local - using a 32-bit local DSN and QuickBooks local to the application. The Sales Order appears correct in QuickBooks.
Taking the same code and connecting it to a 64-bit QRemote DSN connected to a 32-bit qODBC DSN on another machine (via QRemote Server) does not work.
The basic flow is like this:
cnQODBC = New OdbcConnection(ConfigurationManager.AppSettings.Item("QuickBooksConnectionString"))
cnQODBC.Open()
[Repeat for every sales order line item]
Dim cmdQODBC As OdbcCommand = New OdbcCommand("insert into SalesOrderLine (CustomerRefListID, TxnDate, SalesOrderLineClassRefListID, TemplateRefListID, RefNumber, " & "SalesOrderLineItemRefListID, SalesOrderLineDesc, SalesOrderLineQuantity, SalesOrderLineRate, SalesOrderLineAmount, " & "CustomFieldSalesOrderLineOther1, FQSaveToCache) values (??, ??, ????????)", cnQODBC)
cmdQODBC.Parameters.AddWithValue(", "strCustomerListID)
cmdQODBC.Parameters.AddWithValue("", "{d'" & dteInvoiceDate.ToString("yyyy-MM-dd") & "'}")
cmdQODBC.Parameters.AddWithValue(", "strLineClassListID)
cmdQODBC.Parameters.AddWithValue(", "strTemplateListID)
cmdQODBC.Parameters.AddWithValue("", intSalesOrderNumber)
cmdQODBC.Parameters.AddWithValue("", strLineItemListID)
cmdQODBC.Parameters.AddWithValue(", "strain description)
cmdQODBC.Parameters.AddWithValue(", "intQuantity)
cmdQODBC.Parameters.AddWithValue(", "dblLineRate)
cmdQODBC.Parameters.AddWithValue(", "dblLineAmount)
cmdQODBC.ExecuteNonQuery()
[End repeat]
cnQODBC.Close()
cnQODBC = Nothing
cmdQODBC.ExecuteNonQuery()
Solutions:
Integer, double, and long datatype parameter passing in QRemote pass-through string format because of the flow QRemote Client --> QRemote Server --> QODBC Datatype conversion creates the problem in QODBC and C, and due to this issue occurred.
The workaround for this problem is to pass a value in string format instead of basic format, as shown in the example below:
cmdQODBC.Parameters.AddWithValue("", intSalesOrderNumber.ToString()) //cmd.Parameters.AddWithValue("", "3");
cmdQODBC.Parameters.AddWithValue("", intQuantity.ToString()) //cmd.Parameters.AddWithValue("", "44.2");
cmdQODBC.Parameters.AddWithValue("", dblLineRate.ToString()) // cmd.Parameters.AddWithValue("", "113.4");
cmdQODBC.Parameters.AddWithValue("", dblLineAmount.ToString()) //cmd.Parameters.AddWithValue("", "0");
Instead of
cmdQODBC.Parameters.AddWithValue("", intSalesOrderNumber) //cmd.Parameters.AddWithValue("", 3);
cmdQODBC.Parameters.AddWithValue("", intQuantity) //cmd.Parameters.AddWithValue("", 44.2);
cmdQODBC.Parameters.AddWithValue("", dblLineRate) //cmd.Parameters.AddWithValue("", 113.4);
cmdQODBC.Parameters.AddWithValue("", dblLineAmount) //cmd.Parameters.AddWithValue("", 0);
|