Пример #1
0
        /// <summary>
        /// 返回一个Datatable(有参)
        /// </summary>
        /// <param name="sql">语句</param>
        /// <param name="values">参数</param>
        /// <returns>DataTable</returns>
        public static DataTable GetDataSet(string sql, params MySQLDriverCS.MySQLParameter[] values)
        {
            DataSet ds = new DataSet();

            MySQLDriverCS.MySQLCommand cmd = new MySQLDriverCS.MySQLCommand(sql, Connection);
            cmd.Parameters.AddRange(values);
            MySQLDriverCS.MySQLDataAdapter da = new MySQLDriverCS.MySQLDataAdapter(cmd);
            da.Fill(ds);
            return(ds.Tables[0]);
        }
Пример #2
0
        /// <summary>
        /// 返回一个Datatable(无参)
        /// </summary>
        /// <param name="safeSql">语句</param>
        /// <returns>DataTable</returns>
        public static DataTable GetDataSet(string safeSql)
        {
            DataSet ds = new DataSet();

            MySQLDriverCS.MySQLCommand cmd = new MySQLDriverCS.MySQLCommand("set names gbk", Connection);
            cmd.ExecuteNonQuery();
            cmd = new MySQLDriverCS.MySQLCommand(safeSql, Connection);
            MySQLDriverCS.MySQLDataAdapter da = new MySQLDriverCS.MySQLDataAdapter(cmd);
            da.Fill(ds);
            return(ds.Tables[0]);
        }