Ejemplo n.º 1
0
        public DataTable GetData(AppSvrHMI.L3Adapter adapter, string strSql)
        {
            if (adapter.Session == null || !adapter.Session.Opened)
            {
                MessageBox.Show("adapter连接没有打开,请重新登陆");
                return(null);
            }

            adapter.RefreshDataBindings();
            AppSvrIF.Command cmdSQl = new AppSvrIF.Command();
            int iRet = adapter.Session.CreateCommand((int)AppSvrIF.CommandType.QueryBySQL, strSql, "", ref cmdSQl);

            if (iRet != 0)
            {
                MessageBox.Show("创建查询命令失败,请重新登陆");
                return(null);
            }
            iRet = adapter.Session.Execute(cmdSQl);
            if (iRet != 0)
            {
                MessageBox.Show("服务执行出现错误,请重新登陆");
                return(null);
            }
            if (!(cmdSQl.Return is AppSvrIF.Recordset))
            {
                MessageBox.Show("返回结果错误,请重新登陆");
                return(null);
            }
            AppSvrIF.Recordset rs = cmdSQl.Return as AppSvrIF.Recordset;
            if (rs.Tables[0].Rows.Count < 1)
            {
                return(null);
            }
            else
            {
                return(rs.Tables[0]);
            }
        }
Ejemplo n.º 2
0
        public static DataTable GetData(AppSvrHMI.L3Adapter adapter, string strSql)
        {
            if (adapter.Session == null || !adapter.Session.Opened)
            {
                MessageBox.Show("adapterÁ¬½ÓûÓдò¿ª£¬ÇëÖØеǽ");
                return(null);
            }

            adapter.RefreshDataBindings();
            AppSvrIF.Command cmdSQl = new AppSvrIF.Command();
            int iRet = adapter.Session.CreateCommand((int)AppSvrIF.CommandType.QueryBySQL, strSql, "", ref cmdSQl);

            if (iRet != 0)
            {
                MessageBox.Show("´´½¨²éѯÃüÁîʧ°Ü£¬ÇëÖØеǽ");
                return(null);
            }
            iRet = adapter.Session.Execute(cmdSQl);
            if (iRet != 0)
            {
                MessageBox.Show("·þÎñÖ´ÐгöÏÖ´íÎó£¬ÇëÖØеǽ");
                return(null);
            }
            if (!(cmdSQl.Return is AppSvrIF.Recordset))
            {
                MessageBox.Show("·µ»Ø½á¹û´íÎó£¬ÇëÖØеǽ");
                return(null);
            }
            AppSvrIF.Recordset rs = cmdSQl.Return as AppSvrIF.Recordset;
            if (rs.Tables[0].Rows.Count < 1)
            {
                return(null);
            }
            else
            {
                return(rs.Tables[0]);
            }
        }