How to Pass null value byte Field

Posted by Jayakumars under ASP.NET AJAX on 10/19/2011 | Points: 10 | Views : 5927 | Status : [Member] [MVP] | Replies : 3
hi

I am insert the image using byte methods using sp My code below this but following error comes how to solve this
my issue how to pass null value to byte field or how to convert string to byte

my error like this
========================
ex.Message = "Failed to convert parameter value from a String to a Byte[]."


My code like this
====================
if (Session["b"] == null)
{
cmd.Parameters.Add("@StdImagePath", SqlDbType.Image).Value = "";
}

Mark as Answer if its helpful to you


Responses

Posted by: Jpchoudhari on: 10/19/2011 [Member] Starter | Points: 25

Up
0
Down
u r specifying sql db type as image then u have to convert ur image into byte array to save in DB.

Kind Regards,
Jay

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Niladri.biswas on: 10/19/2011 [Member] Platinum | Points: 25

Up
0
Down
Use
DBNull.Value


Best Regards,
Niladri Biswas

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 10/19/2011 [Member] Bronze | Points: 25

Up
0
Down
Do one thing
in procedure where you define parameters, defaine default value to this parameter as null.
means in procedure write this:
@StdImagePath byte=null

and if your session["b"] is null then dnt add this parameter to parameter collection of command object, it will implisitly converted to null

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response