Exemplo n.º 1
0
        /// <summary>
        /// 执行命令
        /// </summary>
        /// <param name="mSqlInfo">SqlHelper信息对象</param>
        /// <param name="connName">数据库连接字符串名称</param>
        public object ExecuteNonQuery(SqlInfo mSqlInfo, string connName)
        {
            object   result;
            Database database = DatabaseFactory.CreateDatabase(connName);

            using (DbCommand command = database.DbProviderFactory.CreateCommand())
            {
                if (mSqlInfo.IsProc)
                {
                    command.CommandType = CommandType.StoredProcedure;
                }
                command.CommandText = mSqlInfo.SqlOrProcName;
                if (mSqlInfo.Parameters != null)
                {
                    foreach (DbParameter param in mSqlInfo.Parameters)
                    {
                        command.Parameters.Add(param);
                    }
                }
                if (mSqlInfo.IsProc)
                {
                    result = database.ExecuteScalar(command);
                }
                else
                {
                    result = database.ExecuteNonQuery(command);
                }
                return(result);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 读取数据表
        /// </summary>
        /// <param name="mSqlInfo">SqlHelper信息对象</param>
        /// <param name="connName">数据库连接字符串名称</param>
        /// <returns></returns>
        public DataTable ExecuteDataTable(SqlInfo mSqlInfo, string connName)
        {
            Database database = DatabaseFactory.CreateDatabase(connName);

            using (DbCommand command = database.DbProviderFactory.CreateCommand())
            {
                if (mSqlInfo.IsProc)
                {
                    command.CommandType = CommandType.StoredProcedure;
                }
                command.CommandText = mSqlInfo.SqlOrProcName;
                if (mSqlInfo.Parameters != null)
                {
                    foreach (DbParameter param in mSqlInfo.Parameters)
                    {
                        command.Parameters.Add(param);
                    }
                }
                DataSet ds = database.ExecuteDataSet(command);
                if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
                {
                    return(ds.Tables[0]);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 执行命令
 /// </summary>
 /// <param name="mSqlInfo">SqlHelper信息对象</param>
 public object ExecuteNonQuery(SqlInfo mSqlInfo)
 {
     return(ExecuteNonQuery(mSqlInfo, _ConnName));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 读取数据集表
 /// </summary>
 /// <param name="mSqlInfo">命令SqlHelper信息对象</param>
 /// <returns></returns>
 public DataSet ExecuteDataSet(SqlInfo mSqlInfo)
 {
     return(ExecuteDataSet(mSqlInfo, _ConnName));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 读取数据表
 /// </summary>
 /// <param name="mSqlInfo">命令SqlHelper信息对象</param>
 /// <returns></returns>
 public DataTable ExecuteDataTable(SqlInfo mSqlInfo)
 {
     return(ExecuteDataTable(mSqlInfo, _ConnName));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 读取一个数据
 /// </summary>
 /// <param name="mSqlInfo">SqlHelper信息对象</param>
 /// <returns></returns>
 public object ExecuteScalar(SqlInfo mSqlInfo)
 {
     return(ExecuteScalar(mSqlInfo, _ConnName));
 }