다음은 오류입니다 (내가 무엇을해야하는지 모르는) :개체 참조는
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
그리고 여기 중지 : 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
쿼리가 결과를 반환하는지 확인하십시오. –
결과가 반환됩니다. 확실 함은 – Marwan