Ejemplo n.º 1
0
        public Dictionary <string, string> GetOptionsFields(Guid id, string sql)
        {
            Dictionary <string, string> list = new Dictionary <string, string>();

            RoadFlow.Platform.DBConnection   bdbconn = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn  = bdbconn.Get(id);
            using (System.Data.IDbConnection conn = bdbconn.GetConnection(dbconn))
            {
                if (conn == null)
                {
                    return(list);
                }
                try
                {
                    conn.Open();
                }
                catch (Exception ex)
                {
                    System.Web.HttpContext.Current.Response.Write("连接数据库出错:" + ex.Message);
                    RoadFlow.Platform.Log.Add(ex);
                }
                List <System.Data.IDataParameter> parList     = new List <System.Data.IDataParameter>();
                System.Data.IDbDataAdapter        dataAdapter = bdbconn.GetDataAdapter(conn, dbconn.Type, sql, parList.ToArray());
                System.Data.DataSet ds = new System.Data.DataSet();
                dataAdapter.Fill(ds);
                foreach (System.Data.DataRow row in ds.Tables[0].Rows)
                {
                    list.Add(row[0].ToString(), row[1].ToString());
                }
                return(list);
            }
        }
Ejemplo n.º 2
0
        public System.Data.DataTable QueryForDataTable(string statementName, StrObjectDict paramObject, StrObjectDict dictParam, System.Collections.Generic.IDictionary <string, System.Data.ParameterDirection> dictParamDirection, out System.Collections.Hashtable htOutPutParameter)
        {
            ISqlMapper sqlMap = this.GetSqlMap();

            System.Data.DataSet dataSet  = new System.Data.DataSet();
            bool           flag          = false;
            ISqlMapSession sqlMapSession = sqlMap.LocalSession;

            if (sqlMapSession == null)
            {
                sqlMapSession = new SqlMapSession(sqlMap);
                sqlMapSession.OpenConnection();
                flag = true;
            }
            System.Data.IDbCommand dbCommand = this.GetDbCommand(sqlMap, statementName, paramObject, dictParam, dictParamDirection, System.Data.CommandType.StoredProcedure);
            try
            {
                dbCommand.Connection = sqlMapSession.Connection;
                System.Data.IDbDataAdapter dbDataAdapter = sqlMapSession.CreateDataAdapter(dbCommand);
                dbDataAdapter.Fill(dataSet);
            }
            finally
            {
                if (flag)
                {
                    sqlMapSession.CloseConnection();
                }
            }
            htOutPutParameter = new System.Collections.Hashtable();
            foreach (System.Data.IDataParameter dataParameter in dbCommand.Parameters)
            {
                if (dataParameter.Direction == System.Data.ParameterDirection.Output)
                {
                    htOutPutParameter[dataParameter.ParameterName] = dataParameter.Value;
                }
            }
            return(dataSet.Tables[0]);
        }