I have a small C# console program that retrieves an item list from quickbooks, and I am trying to figure out how to expose that data to Microsoft Access. It is in XML format.
I want to retrieve the data in real-time, since it only takes about a second to get the data, whenever Access calls for it. I am using Access 2003 and VS 2010.
If there is a way to do this with VBA that would work fine as well. I can get the XML data using VBA already, but I don't know how to go from there.
Here is the code I use in C#:
public string DoQBQuery(XmlDocument doc)
{
bool sessionBegun = false;
bool connectionOpen = false;
RequestProcessor2 rp = null;
string ticket = "";
try
{
//Create the Request Processor object
rp = new RequestProcessor2();
//Connect to QuickBooks and begin a session
rp.OpenConnection2("", "QB Transaction Item Retriever", QBXMLRPConnectionType.localQBD);
connectionOpen = true;
ticket = rp.BeginSession("", QBFileMode.qbFileOpenDoNotCare);
sessionBegun = true;
//Send the request and get the response from QuickBooks
string responseStr = rp.ProcessRequest(ticket, doc.OuterXml);
//End the session and close the connection to QuickBooks
rp.EndSession(ticket);
sessionBegun = false;
rp.CloseConnection();
connectionOpen = false;
return responseStr;
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error");
if (sessionBegun)
rp.EndSession(ticket);
if (connectionOpen)
rp.CloseConnection();
throw;
}
}