Beispiel #1
0
        //获取SqlDataAdapter对象
        public static SqlDataAdapter GetSDA(string cmdText)
        {
            SqlConnection  con = DBhelper.GetConnection();
            SqlCommand     cmd = new SqlCommand(cmdText, con);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);

            return(sda);
        }
Beispiel #2
0
        //查询个数
        public static int GetCount(string cmdText)
        {
            SqlConnection con = DBhelper.GetConnection();

            con.Open();
            SqlCommand cmd   = new SqlCommand(cmdText, con);
            int        count = (int)cmd.ExecuteScalar();

            return(count);
        }
Beispiel #3
0
        //获取inder页的数据集
        //index:页
        //maxRecords:每页显示的记录数
        //(index-1)*maxRecords:index页记录的起始索引
        //返回值第index页的结果集
        public static DataTable GetPartTable(string cmdText, int index, int maxRecords)
        {
            SqlConnection  con = DBhelper.GetConnection();
            SqlCommand     cmd = new SqlCommand(cmdText, con);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet        ds  = new DataSet();

            sda.Fill(ds, (index - 1) * maxRecords, maxRecords, "st");
            DataTable dt = ds.Tables["st"];

            return(dt);
        }
Beispiel #4
0
        //获取查询到的结果集
        public static SqlDataReader GetDR(string cmdText, SqlParameter[] prm)
        {
            SqlConnection con = DBhelper.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand(cmdText, con);

            cmd.Parameters.AddRange(prm);
            SqlDataReader dr = cmd.ExecuteReader();

            return(dr);
        }
Beispiel #5
0
        //添加,删除,更新 操作
        public static int Add(string cmdText, SqlParameter[] sprms)
        {
            SqlConnection con = DBhelper.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand(cmdText, con);

            cmd.Parameters.AddRange(sprms);
            int count = cmd.ExecuteNonQuery();

            return(count);
        }