简体   繁体   English

C#Quickbooks查询客户COMException被捕获

[英]c# Quickbooks query customer COMException was caught

I'm new in integrating Quickbooks to c# and I'm having and error in BeginSession 我是将Quickbooks集成到c#中的新手,并且BeginSession中出现错误

Here is my code 这是我的代码

bool sessionBegun = false;
            bool connectionOpen = false;
            QBSessionManager sessionManager = null;

            try
            {
                //Create the session Manager object
                sessionManager = new QBSessionManager();

                //Create the message set request object to hold our request
                IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 10, 0);
                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;

                BuildCustomerAddRq(requestMsgSet);

                //Connect to QuickBooks and begin a session
                sessionManager.OpenConnection("", "Sample Code from OSR");
                connectionOpen = true;
                sessionManager.BeginSession("", ENOpenMode.omDontCare);
                sessionBegun = true;

                //Send the request and get the response from QuickBooks
                IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);

                //End the session and close the connection to QuickBooks
                sessionManager.EndSession();
                sessionBegun = false;
                sessionManager.CloseConnection();
                connectionOpen = false;

                WalkCustomerAddRs(responseMsgSet);

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error");
                if (sessionBegun)
                {
                    sessionManager.EndSession();
                }
                if (connectionOpen)
                {
                    sessionManager.CloseConnection();
                }
            }

btw I just copy this code in this link enter link description here 顺便说一句,我只是在此链接中复制此代码,在此处输入链接描述

and here is my error 这是我的错误

在此处输入图片说明

错误消息表明您需要将文件名传递给BeginSession调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM