问题
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