当前位置:编程学习 > JAVA >>

java实现KISProfessionalPlugin接口,通过jacob包

package kis.demo;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
  
public class Demo  
{  
    public static String ShowMsg(String str){  
        String res="";  
        String connString = "ConnectString={Provider=SQLOLEDB.1;User ID=KISAdmin;Password=ypbwkfyjhyhgzj;DataSource=msde; "
            + "Initial Catalog=KIS_Sample};UserName=Manager;UserID=16394;DBMS Name=Microsoft SQL Server;"
            + "DBMS Version=2000;SubID=super;AcctType=gy;Setuptype=industry";
        try {
            ActiveXComponent pp = new ActiveXComponent("KISProfessionalPlugin.clsDatabase");  
            Dispatch myCom = (Dispatch) pp.getObject();  
            Variant result = Dispatch.call( myCom, "InitConnection", connString) ;  
            res=result.toString();
            System.out.println("-----------------------"+res);
            saveData();
} catch (Exception e) {
res = "";
e.printStackTrace();
}
        return res;  
    }
    
    public static boolean saveData(){
     boolean flag = true;
     ActiveXComponent activeXComponent = new           ActiveXComponent("KISProfessionalPlugin.Voucher");
     Dispatch dispatch = (Dispatch) activeXComponent.getObject();
     Dispatch.put(dispatch, "VchGroup", "收");
     Dispatch.put(dispatch, "VchAttachment", 2);
Dispatch.put(dispatch, "VchDate", "2009-06-01");
Dispatch.call(activeXComponent, "InsertEntry");
     Dispatch.put(dispatch, "VchExp", "周转材料");
     Dispatch.put(dispatch, "AcctID", "1411");
     Dispatch.put(dispatch, "VchDebit", 100);
     Dispatch.put(dispatch, "VchCyid", "RMB");
     Dispatch.put(dispatch, "VchExp", "销售出库");
     Dispatch.put(dispatch, "AcctID", "6001");
     Dispatch.put(dispatch, "VchDebit", 100);
     Dispatch.put(dispatch, "VchCyid", "RMB");
     Dispatch.put(dispatch, "ItemID", "152,100,162");
     Dispatch.put(dispatch, "VchTransID", "9988776");
     Dispatch.call(activeXComponent, "InsertEntry");
     Dispatch.call(activeXComponent, "Save",dispatch);
     return flag;
    }
    public static void main(String[] args)  
    {  
        String strRet = Demo.ShowMsg("welcome weigongwan!");  
        System.out.println(strRet);  
    }  



现在报错:
         -----------------------null
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: InsertEntry
Description: An unknown COM error has occured.
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.call(Dispatch.java)
at kis.demo.Demo.saveData(Demo.java:44)
at kis.demo.Demo.ShowMsg(Demo.java:29)
at kis.demo.Demo.main(Demo.java:63)
求高手指导。。我之前用简单例子已测试jacob包的配置没有问题,现在在掉InsertEntry函数时报的错
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,