求教啊C#一直提示"未将对象引用设置到对象的实例"咋回事啊
求教啊,C#一直提示"未将对象引用设置到对象的实例",怎么回事啊?
这是错误截图
下面是代码
这是SqlHelper的
这是错误截图
下面是代码
public List<Customer> GetALL()
{
List<Customer> customers = new List<Customer>();
customers=SqlHelper.ExcuteReader("select * from T_Customer");//就是在这里抛出异常的,可是SqlHelper是个静态类啊
return customers;
}
这是SqlHelper的
public static List<Customer> ExcuteReader(string str, params SqlParameter[] para)
{
using (SqlConnection sql = new SqlConnection(connection))
{
sql.Open();
using (SqlCommand com = sql.CreateCommand())
{
com.CommandText = str;
com.Parameters.AddRange(para);
using(SqlDataReader reader=com.ExecuteReader())
{
if (reader==null)
{
return null;
}
List<Customer> customers=new List<Customer>();