Reputation: 430
I have a form with information about of every Person in a society.
In this form there is an image which must be generated from SQL server. I don't know how to generate this image Fromm sql to c# in image control using a stored procedure which display image according to a CODE. I'm working in an application in ASP(c#)
this is my procedure in sql :
create proc uploadImage
@ppr int
as
if exists (select idimg from Images where idimg = ( select codeimg from Agent where PPR=@ppr))
begin
select image from Images where idimg = ( select codeimg from Agent where PPR=@ppr)
end
i have already my code but it's not completed :
try
{
c.cmd = c.cn.CreateCommand();
c.cmd.CommandText = "uploadImage";
c.cmd.CommandType = CommandType.StoredProcedure;
if (c.cn.State == ConnectionState.Closed)
{
c.cn.Open();
}
c.cmd.Parameters.Add("@ppr", SqlDbType.Int);
c.cmd.Parameters["@ppr"].Value = Session["Code"];
SqlDataReader dr = c.cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
**// here where i will treat my image ..i think**
}
dr.Close();
}
Upvotes: 0
Views: 144
Reputation: 1500
I think that he correct way is:
Upvotes: 2