如果存储过程值为null,如何显示消息

时间:2015-11-29 16:43:38

标签: c# stored-procedures

我的代码是......

public DataTable GET_IMAGE_PRODUCT(int ID)
{
    DAL.DataAccessLayer DAL = new DAL.DataAccessLayer();
    DataTable Dt = new DataTable();
    SqlParameter[] param = new SqlParameter[1];
    param[0] = new SqlParameter("@ID", SqlDbType.VarChar,50);
    param[0].Value = ID;
    Dt = DAL.SelectData("GET_IMAGE_PRODUCT", param);
    DAL.Close();
    return Dt;
}

private void button6_Click(object sender, EventArgs e)
{
    FRM_PREVIEW frm = new FRM_PREVIEW();
    byte[] image = (byte[])prd.GET_IMAGE_PRODUCT(this.dataGridView1.CurrentRow.Cells[0].Value.GetHashCode()).Rows[0][0];
    MemoryStream ms = new MemoryStream(image);
    frm.pictureBox1.Image = Image.FromStream(ms);
    frm.ShowDialog();
}

所以如果没有图像,我想显示一条消息。

0 个答案:

没有答案