C#连接SAP并调用SAP RFC 2011-09-04 16:55:02| 分类: C# | 标签: |举报 |字号大
中
小 订阅
1.创建一个空项目Project1,系统会自动生成一个对应的解决方案Project1
2.右键这个项目名字,添加三个引用(基于COM组件):SAP Logon Control,SAP Remote Function Call Control,SAP Remote Factory.
3.右键这个项目名字->添加->新建项->代码文件,编码如下:
using System;
using SAPFunctionsOCX;
using SAPLogonCtrl;
using SAPTableFactoryCtrl;
class Welcome
{
static void Main()
{
System.Threading.Thread s = new System.Threading.Thread(new System.Threading.ThreadStart(test)); //Create a new thread and set the method test() run in this thread
s.SetApartmentState(System.Threading.ApartmentState.STA); //Set the run mode 'STA',否则会在functions.Connection = conn;时抛出异常Bad variant type
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载