DataAdapter 填充Datatable 返回的数据为空,但是我把调用的sql语句到数据库里查询却能查出数据。不知道这是什么问题 调用
public static DataTable GetDataTable(string strSelect, string strWhere, string strTableName, string strOrder)
{
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@StrSelect",strSelect),
new SqlParameter("@strWhere",strWhere),
new SqlParameter("@strTableName", strTableName),
new SqlParameter("@strOrder", strOrder)
};
return SqlOperate.SqlHelper.ExecuteTable(CommandType.StoredProcedure, "SP_SelectByWhere", param);
}
public static DataTable ExecuteTable(string cmdText)
{
SqlCommand cmd = new SqlCommand();
using (SqlConnection connection = new SqlConnection(ConnectionString))
{
PrepareCommand(cmd, connection, null, CommandType.Text, cmdText, null);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable dataTable = new DataTable();
DataSet ds = new DataSet();
adapter.Fill(ds, "DataTable");
dataTable=ds.Tables["DataTable"];
cmd.Parameters.Clear();
return dataTable;
}
}
犯罪嫌疑人X
慕丝7291255
Cats萌萌
喵喔喔