易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net 读取SAP数据(rfc形式全过程)

平台:vs2005,ecc6 ,orcale 数据库
1.首先用se37,建立一个读取函数,如图
2.先添加三个com组件Interop.SAPFunctionsOCX.dll,Interop.SAPLogonCtrl.dll,Interop.SAPTableFactoryCtrl.dll
下面的代码我是转载其他网站,
以web形式对function module进行调用与form形式基本一样,唯一值得注意的地方就是:"An ActiveX control must be run in an STA apartment. Because the attribute STAThread is applied to the Main method of a WinForm class by default with a WinForms Project, the main thread of your app will run in STA mode.".也就是说有些AcrtiveX控件或者Com组件必须运行在单线程单元下(STA:Single  Thread  Apartment ),否则的话会抛出“Bad variant type”异常。解决方案为:新开一个线程,并将该线程的运行模式设置为STA,然后再改线程下对Com组件或者ActiveX控件进行调用。
      对应到我们的事例中,如果不使用STA模式运行,我们可以连接到SAP系统,但调用Function Module的时候会抛出“Bad variant type”异常。所以要讲调用Function Module的代码在新开的线程中执行。具体步骤如下:
      一,添加对Interop.SAPFunctionsOCX.dll以及Interop.SAPLogonCtrl.dll和Interop.SAPTableFactoryCtrl.dllcom组件的引用。
      二,新开一个线程,并将该线程的运行模式设置为STA. 并将登录SAP系统以及调用Function module的方法运行在该线程下!代码如下:
     protected void Button1_Click(object sender, EventArgs e)
    {
        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'
     &


相关文档:

asp.net链接Access数据库字符串正确方法

在web  config中  作如下配置:
<connectionStrings>
    <add name="ydycon" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=|DataDirectory|ydy.mdb" providerName="System.Data.OleDb"/>
 
  </connectionStrings>
在.net文件中应用链接 ......

asp.net操作数据库相关[导入]

使用DataRelation类创建关系并利用父/子关系读取数据示例
 void Page_Load(object sender, System.EventArgs e)
{
// 连接字符串和 SQL 语句
string ConnString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionSqlServer"];
......

ASP.NET实现局部刷新GridView

 <% @ Page Language = " C# "  %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< script runat ="server" >  
  System.Data.DataView Crea ......

如何学习ASP.net技术

完成任何一个事情,目标和流程是我们首先要清晰的。
学习ASP.net技术也是这样,
我这里把ASP.net完全掌握需要的一个推荐学习流程告诉大家。
大家可以参考一下,有些不一定要完全掌握,但一定要了解了解。
等有了合理的知识结构,再来整体提高,有时候,可以融汇贯通,效果更好。
有啥学习上的问题,可以发群邮件问斯琴 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号