예제 #1
0
파일: DbProvider.cs 프로젝트: joleye/1.6
        public DataTable find(string table, int page, int pagesize,string order, params object[] obj)
        {
            int startRecords;
            if (page < 1)
                startRecords = 0;
            else
                startRecords = (page - 1) * pagesize;

            DbSqlstring dstr = new DbSqlstring();
            string table_sql = dstr.query_select(table,order, obj);

            OleDbConnection cn = getConn().get();
            OleDbDataAdapter dr = new OleDbDataAdapter(table_sql, cn);
            try
            {
                for (int i = 0; i < obj.Length; i = i + 4)
                {
                    dr.SelectCommand.Parameters.Add("@" + obj[i], chtype(obj[i + 1].ToString()), obj[i + 2].ToString().Length);
                    dr.SelectCommand.Parameters["@" + obj[i]].Value = obj[i + 3].ToString();
                }
            }
            catch (Exception ex)
            {

                die(ex.Message.ToString());
            }

            DataSet ds = new DataSet();
            dr.Fill(ds, startRecords, pagesize, "ds");
            dr.Dispose();
            cn.Close();

            j_read_db_num++;
            return ds.Tables[0];
        }
예제 #2
0
파일: DbProvider.cs 프로젝트: joleye/1.6
        /// <summary>
        /// 返回单行数据
        /// </summary>
        /// <param name="table"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public DataRow get_info(string table, params object[] obj)
        {

            DbSqlstring dstr = new DbSqlstring();
            string table_sql = dstr.query_select(table, obj);
            OleDbConnection cn = getConn().get();
            OleDbDataAdapter dr = new OleDbDataAdapter(table_sql, cn);
            for (int i = 0; i < obj.Length; i = i + 4)
            {
                dr.SelectCommand.Parameters.Add("@" + obj[i], chtype(obj[i + 1].ToString()), obj[i + 2].ToString().Length);
                dr.SelectCommand.Parameters["@" + obj[i]].Value = obj[i + 3].ToString();
            }

            DataSet ds = new DataSet();
            dr.Fill(ds);
            dr.Dispose();
            cn.Close();

            j_read_db_num++;
            if (ds.Tables[0].Rows.Count > 0)
                return ds.Tables[0].Rows[0];
            else
            {
                DataTable dt = new DataTable("dt");
                return dt.NewRow();
            }
        }
예제 #3
0
파일: FrontendBll.cs 프로젝트: joleye/1.6
 /// <summary>
 /// Ö±½ÓsqlÓï¾ä
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public DataTable get_sql(string sql)
 {
     sql = new DbSqlstring().format_sql(sql);
     return DataSetExecuteText(sql).Tables[0] ;
 }