C# SapDataReader cmd.ExecuteReader() Error

心不动则不痛 提交于 2019-12-11 14:53:56

问题


I have the following problem. I want to connect my C# application with our SAP server, which works fine, but in addition, I want to a execute an RFC and read the output with ExecuteReader().

using Microsoft.Data.SapClient;


namespace SAPconnect2
{
    class Program
    {
        static void Main(string[] args)
        {
            string connstr = "ASHOST=xxx; SYSNR=00; CLIENT=100; LANG=EN; USER=xxx; PASSWD=xxx;";

            using (SapConnection conn = new SapConnection(connstr))
            {
                conn.Open();

                using (SapCommand cmd = (SapCommand)conn.CreateCommand())
                {
                    cmd.CommandText = "exec zrfc_test";
                    using (SapDataReader dr = (SapDataReader)cmd.ExecuteReader())
                    {


                    }
            }
        }
    }
}

}

But when I execute the programme, I get the following error: additional information: Incorrect token found, expected a token of the following type: Describe, Execute, Select. [XtractQL/Command]

I also tried to follow this guide: https://msdn.microsoft.com/en-us/library/cc185499(v=bts.10).aspx

But when I remove (SapCommand) before conn.CreateCommand() and (SapDataReader) before cmd.ExecuteReader(), I generate error CS0266.

What do I have to do, to get this programme running?

来源:https://stackoverflow.com/questions/47431713/c-sharp-sapdatareader-cmd-executereader-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!