这是错误:
异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例。
它停在这里:con.Open();
这是代码:
SqlConnection con = new SqlConnection(DBHelper.connection);
SqlCommand com = new SqlCommand();
con = com.Connection;
con.Open();
com.CommandType = CommandType.Text;
com.CommandText = "select catname,catdescription,photo from category where catid=" + catselectddl.SelectedValue ;
SqlDataReader dr= com.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
DataRow drr;
drr=dt.Rows[0];
con.Close();
错误:
Line 19: SqlCommand com = new SqlCommand();
Line 20: con = com.Connection;
Line 21: con.Open(); // here the error
Line 22: com.CommandType = CommandType.Text;
Line 23: com.CommandText = "select catname,catdescription,photo from category where catid=" + catselectddl.SelectedValue