내 프로젝트에도록 SqlConnection을 가지고 난 내 쿼리 결과어떻게 제어 할 수
public IEnumerable<Product> ListPrpductByCategory(int ID)
{
var dr = db.ExecuteReader(@"SELECT P.ID,P.CategoryID,P.Name,P.SupplierID,p.UnitPrice,p.UnitsInStock,pp.PicturePath
FROM Products P
LEFT JOIN ProductPhoto PP ON p.ID=PP.ProductID
WHERE [email protected]",
Values: new object[] { ID });
while (dr.Read())
{
yield return new Product()
{
ID = dr.GetInt32(0),
CategoryID = dr.GetInt32(1),
SupplierID = dr.GetInt32(3),
Name = dr.GetString(2),
UnitPrice = dr.GetDecimal(4),
UnitInstock = dr.GetInt16(5),
PicturePath = dr.GetString(6)
};
}
dr.Close();
//...
}
으로 제어 할 그것은 나를 내가 원하는 오류 던져
if(dr.GetString(6)==null)
PicturePath="Noimage.jpg";
같은 제어 dr.GetString(6)
내가 어떻게 할 수 있습니까? 나는 보통으로 그 쓰기
if(dr.IsDBNull(6))
PicturePath = "Noimage.jpg";
else
PicturePath = dr.GetString(6);
감사합니다. llya ıt worked :) –