C# 读取表格返回数据顺序与表格中数据反了,初步估计是因为前面是空值,从最后一行开始读取了。
如果按升序读取的话,需要加order by
"SELECT * FROM " + _tablename + " ORDER BY " + colnames[0] + " ASC";
降序:
"SELECT * FROM " + _tablename + " ORDER BY " + colnames[0] + " DESC";
程序举例:
public static string[,] get_a_whole_table_str2Darr_constr2(string _connectionstr, string _tablename)
{
string sql1 = "select * from " + _tablename;
OleDbConnection OleDbConnection1 = new OleDbConnection();
OleDbConnection1.ConnectionString = _connectionstr;
OleDbConnection1.Open();
OleDbDataAdapter OleDbDataAdapter1 = new OleDbDataAdapter