易截截图软件、单文件、免安装、纯绿色、仅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'
     &


相关文档:

获取真实IP和代理IP (asp.net C#)

程序代码
public static string GetRealIP()
{
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
}
else
{
ip = requ ......

Asp.net常用的51个代码(非常实用)

Asp.net常用的51个代码(非常实用)
1.//弹出对话框.点击转向指定页面
CODE:
Response.Write(&quot;<script>window.alert('该会员没有提交申请,请重新提交!')</script>&quot;);
Response.Write(&quot;<script>window.location ='http://www.51aspx.com/bizpulic/upmeb.aspx'</script&g ......

asp.net 网站性能优化

1. 数据库访问性能优化
  数据库的连接和关闭
  访问数据库资源需要创建连接、打开连接和关闭连接几个操作。这些过程需要多次与数据库交换信息以通过身份验证,比较耗费服务器资源。ASP.NET中提供了连接池(Connection Pool)改善打开和关闭数据库对性能的影响。系统将用户的数据库连接放在连接池中,需要时取出,关闭 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号