This code is interfacing to a COM object that's part of the sdk. You have to add a reference to "Interop.QB....somethingorother".
I'm running a query to get information from QB. I've asked for the 2 inventory items, 563 and ND-105. If you look near the top of the XML there's a CreateElement for ("ItemInventoryQueryRq"). This defines the type of operation. There's a file among the docs QB supplies that defines all the types of XML files you can create.
This line in the file:
qbXMLMsgsRq.SetAttribute("onError", "stopOnError");
Might help with the duplicates. Once again, I don't have the docs here. But I believe the other possible value for the "OnError" attribute is something that tells QB to ignore errors and continue.
>per emails from nSoftware, I believe i have to use the SDK to query for Items (or update to a newer ver$ion). So these are the 2 items ("563" and "ND-105") that u are pushing over? Is this code performing a search first though? I find that it errors out if some things... like items... are not unique.
>
>
>XmlElement itemNameRq = inputXMLDoc.CreateElement("FullName");
> itemNameRq.InnerText = "563";
> itemQryRq.AppendChild(itemNameRq);
>
> itemNameRq = inputXMLDoc.CreateElement("FullName");
> itemNameRq.InnerText = "ND-105";
> itemQryRq.AppendChild(itemNameRq);
>
>
>
>
>>This is the code to create a qbxml file and sending it to QB:
>>
>>
>> XmlDocument inputXMLDoc = new XmlDocument();
>> inputXMLDoc.AppendChild(inputXMLDoc.CreateXmlDeclaration("1.0", null, null));
>> inputXMLDoc.AppendChild(inputXMLDoc.CreateProcessingInstruction("qbxml", "version=\"2.0\""));
>> XmlElement qbXML = inputXMLDoc.CreateElement("QBXML");
>> inputXMLDoc.AppendChild(qbXML);
>> XmlElement qbXMLMsgsRq = inputXMLDoc.CreateElement("QBXMLMsgsRq");
>> qbXML.AppendChild(qbXMLMsgsRq);
>> qbXMLMsgsRq.SetAttribute("onError", "stopOnError");
>> XmlElement itemQryRq = inputXMLDoc.CreateElement("ItemInventoryQueryRq");
>> qbXMLMsgsRq.AppendChild(itemQryRq);
>>
>> XmlElement itemNameRq = inputXMLDoc.CreateElement("FullName");
>> itemNameRq.InnerText = "563";
>> itemQryRq.AppendChild(itemNameRq);
>>
>> itemNameRq = inputXMLDoc.CreateElement("FullName");
>> itemNameRq.InnerText = "ND-105";
>> itemQryRq.AppendChild(itemNameRq);
>>
>> string input = inputXMLDoc.OuterXml;
>> //step3: do the qbXMLRP request
>> RequestProcessor2 rp = null;
>> string ticket = null;
>> string response = null;
>> try
>> {
>> rp = new RequestProcessor2();
>> rp.OpenConnection("", "IDN Inventory Item Request");
>> ticket = rp.BeginSession("", QBFileMode.qbFileOpenDoNotCare);
>> response = rp.ProcessRequest(ticket, input);
>>
>> }
>> catch (System.Runtime.InteropServices.COMException ex)
>> {
>> MessageBox.Show("COM Error Description = " + ex.Message, "COM error");
>> return;
>> }
>> finally
>> {
>> if (ticket != null)
>> {
>> rp.EndSession(ticket);
>> }
>> if (rp != null)
>> {
>> rp.CloseConnection();
>> }
>> };
>>
>> //step4: parse the XML response and show a message
>> XmlDocument outputXMLDoc = new XmlDocument();
>> outputXMLDoc.LoadXml(response);
>>
>>
>>There is a section in the above where I'm doing 2 "CreateElements" with "FullName". Which is the item key. I don't have the SDK with me, but I remember that you can pass either FullName or one other column to retrieve individual items.
>>
>>This above isn't exactly perfect. It's a combination of reading how to accomplish XML in C# 2.0 and QB examples which are done in V1.0, I think. The books recommend XmlDataDocument, added in V2.0, but I haven't tried it yet.
>>
>>Is this what you're looking for?
>>
>>
>>>Avoiding your checkbox question, are you searching the QB database before adding new ITEMS or are you just flagging items as having already been exported to QB? I have been using "nSoftware's IBIZ QB control" (
http://www.nsoftware.com/ibiz/QuickBooks/) and the earlier version that i have doesnt provide for searching of items. Do you have some code u can share on how thats done?
>>>
>>>
>>>>I'm creating a little system to interface to quickbooks inventory. I want the user to hit a button that will populate the system with the inventory items from qb. Then click a checkbox in the grid that will indicate which items that are necessary for the process.
>>>>
>>>>Using the smarttags I've added a checkbox column to the grid. Then in code, after I've retrieved the xml file from qb, I add 2 more columns for the item key and description.
>>>>
>>>>I noticed a little issue. If I click on any of the grid columns to reorder the grid, any checks are cleared.
>>>>
>>>>Any suggestions on what I need to set for the checkboxes to maintain their values?
>>>>
>>>>Thanks,
>>>>
>>>>PF
(On an infant's shirt): Already smarter than Bush