Click here to Skip to main content
16,007,111 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Convert image to binary and back to image Pin
J Liang11-Jun-08 17:02
J Liang11-Jun-08 17:02 
GeneralRe: Convert image to binary and back to image Pin
N a v a n e e t h11-Jun-08 17:18
N a v a n e e t h11-Jun-08 17:18 
GeneralRe: Convert image to binary and back to image Pin
J Liang11-Jun-08 17:37
J Liang11-Jun-08 17:37 
GeneralRe: Convert image to binary and back to image Pin
N a v a n e e t h11-Jun-08 17:24
N a v a n e e t h11-Jun-08 17:24 
GeneralRe: Convert image to binary and back to image Pin
J Liang11-Jun-08 19:13
J Liang11-Jun-08 19:13 
GeneralRe: Convert image to binary and back to image Pin
N a v a n e e t h11-Jun-08 20:44
N a v a n e e t h11-Jun-08 20:44 
GeneralRe: Convert image to binary and back to image Pin
J Liang11-Jun-08 22:52
J Liang11-Jun-08 22:52 
GeneralRe: Convert image to binary and back to image [modified] Pin
J Liang11-Jun-08 23:12
J Liang11-Jun-08 23:12 
I think i realized there is a place where could cause all these.

I uses a stored procedure to get the binary data out but I'd declare in my coding as byte[]. So it gives me a problem when I do

SqlParameter objParam2;

objParam2 = myCommand.Parameters.Add("@cpyLogo", SqlDbType.Binary, 5000);

objParam2.Direction = ParameterDirection.Output;

myCommand.ExecuteNonQuery();

if (objParam2.Value == DBNull.Value)
            {
                cpyLogo = null;
            }
            else
            {
                cpyLogo = Convert.ToByte(objParam2.Value); <--Note it is not converting to byte[]
            }


So I found in the internet where they uses this function to convert to byte array

public static byte[] ConvertStringToByteArray(string stringToConvert)
    {
        return (new UnicodeEncoding()).GetBytes(stringToConvert);
    }


And I changed my code to

if (objParam2.Value == DBNull.Value)
            {
                cpyLogo = null;
            }
            else
            {
                cpyLogo = ConvertStringToByteArray(objParam2.Value.ToString());
            }


Later I realized I'd read some where that I should not threat binary data as string (objParam2.Value.ToString()), could this be the problem? Or there is another way to change my objParam2.Value to byte array?

I think now what I need to do is to find out how to convert binary to byte array first.

modified on Thursday, June 12, 2008 5:21 AM

QuestionPlease I nees help with AccessDataSource InsertCommand Pin
nisha428511-Jun-08 13:14
nisha428511-Jun-08 13:14 
AnswerRe: Please I nees help with AccessDataSource InsertCommand Pin
Christian Graus11-Jun-08 15:33
protectorChristian Graus11-Jun-08 15:33 
GeneralRe: Please I nees help with AccessDataSource InsertCommand [modified] Pin
nisha428512-Jun-08 7:51
nisha428512-Jun-08 7:51 
Questiontables Pin
jds120711-Jun-08 9:47
jds120711-Jun-08 9:47 
AnswerRe: tables Pin
Christian Graus11-Jun-08 10:37
protectorChristian Graus11-Jun-08 10:37 
GeneralRe: tables Pin
jds120711-Jun-08 12:03
jds120711-Jun-08 12:03 
Questionhw to get checked rows of gridview which is bubbled with checkboxes in c#.net Pin
senpriya11-Jun-08 9:24
senpriya11-Jun-08 9:24 
AnswerRe: hw to get checked rows of gridview which is bubbled with checkboxes in c#.net Pin
Christian Graus11-Jun-08 9:30
protectorChristian Graus11-Jun-08 9:30 
Questionhw to add pop up calende r in gridview using c# Pin
senpriya11-Jun-08 9:20
senpriya11-Jun-08 9:20 
AnswerRe: hw to add pop up calende r in gridview using c# Pin
Parwej Ahamad11-Jun-08 17:38
professionalParwej Ahamad11-Jun-08 17:38 
Questionhw to add pop up calender in gridview Pin
senpriya11-Jun-08 9:18
senpriya11-Jun-08 9:18 
AnswerRe: hw to add pop up calender in gridview Pin
Christian Graus11-Jun-08 9:31
protectorChristian Graus11-Jun-08 9:31 
Questionhow to set fontsize,color in .cs file(i know to do in .aspx page hw to do in codebehind Pin
senpriya11-Jun-08 9:17
senpriya11-Jun-08 9:17 
AnswerRe: how to set fontsize,color in .cs file(i know to do in .aspx page hw to do in codebehind Pin
Christian Graus11-Jun-08 9:31
protectorChristian Graus11-Jun-08 9:31 
QuestionSimple GridView Question, Really? Anyone help? Pin
Csharp027611-Jun-08 7:52
Csharp027611-Jun-08 7:52 
AnswerRe: Simple GridView Question, Really? Anyone help? Pin
Christian Graus11-Jun-08 8:05
protectorChristian Graus11-Jun-08 8:05 
QuestionASP TextBox selection event. Pin
Steve Holdorf11-Jun-08 6:08
Steve Holdorf11-Jun-08 6:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.