Getting Byte[] data with MySQL -Cast(... AS BINARY)

Discussion in 'ASP .Net' started by ist, Mar 6, 2008.

  1. ist

    ist Guest

    Hi,

    I am trying to get (and transfer over ASP.NET) some encrypted data
    from some MySQL fields. Since the data contains many unicode
    characters, I tried to get the data as a series of ASCII values,
    transfer those numeric values over ASP.NET. I had no problem doing
    this on my local computer, by getting the field with "cast(field as
    BINARY)" so that on ASP.NET I have a byte[] array.Then send every
    field of array over ASP.Net.

    However when I upload application to remote server, "cast(field as
    BINARY)" returns field data as String type. I have tried many ways to
    convert this string data to byte array, however data always become
    corrupted. So I have to get data as a byte array directly from MySQL.

    As I've said, I had no problem doing this on my local computer,
    however, on my local computer I was connecting to same computer using
    same driver (MySQL Odbc 3.51), so when I upload the ASP.NET page to
    remote server, ONLY thing that is changing is location and -maybe-
    ASP.NET version (I am sure both are ASP.NET 2 , maybe different
    builds)

    So, the bottom line is: I am trying to get MySQL data as byte[] type,
    on local web server I have no problem, on remote web server
    (connecting to SAME MySQL Server) I get data as String, instead of
    Byte[]. How can I achieve same result on remote server?
     
    ist, Mar 6, 2008
    #1
    1. Advertising

  2. First, let's step back. You are using encrypted data, which means you have
    char > 255. This was a problem in traditional ASP, but should not be a
    problem in ASP.NET, as strings are Unicode by default. I have not played
    extensively with MySQL, so I cannot be completely sure, but I have done
    extensive work with encryption in other databases, requiring no need to pull
    as binary.

    I would try pulling the string out straight rather than running from string
    to byte[] and back to Unicode string.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    *************************************************
    | Think outside the box!
    |
    *************************************************
    "ist" <> wrote in message
    news:...
    > Hi,
    >
    > I am trying to get (and transfer over ASP.NET) some encrypted data
    > from some MySQL fields. Since the data contains many unicode
    > characters, I tried to get the data as a series of ASCII values,
    > transfer those numeric values over ASP.NET. I had no problem doing
    > this on my local computer, by getting the field with "cast(field as
    > BINARY)" so that on ASP.NET I have a byte[] array.Then send every
    > field of array over ASP.Net.
    >
    > However when I upload application to remote server, "cast(field as
    > BINARY)" returns field data as String type. I have tried many ways to
    > convert this string data to byte array, however data always become
    > corrupted. So I have to get data as a byte array directly from MySQL.
    >
    > As I've said, I had no problem doing this on my local computer,
    > however, on my local computer I was connecting to same computer using
    > same driver (MySQL Odbc 3.51), so when I upload the ASP.NET page to
    > remote server, ONLY thing that is changing is location and -maybe-
    > ASP.NET version (I am sure both are ASP.NET 2 , maybe different
    > builds)
    >
    > So, the bottom line is: I am trying to get MySQL data as byte[] type,
    > on local web server I have no problem, on remote web server
    > (connecting to SAME MySQL Server) I get data as String, instead of
    > Byte[]. How can I achieve same result on remote server?
     
    Cowboy \(Gregory A. Beamer\), Mar 6, 2008
    #2
    1. Advertising

  3. ist

    ist Guest

    Hi,
    I've 'played' with some MySQL connection properties (Character set,
    collation etc.), and converted String data to byte array at ASP.NET
    side ('played' here with some combinations too) and got a good result
    for now. Thanks..



    On 6 Mart, 16:44, "Cowboy \(Gregory A. Beamer\)"
    <> wrote:
    > First, let's step back. You are using encrypted data, which means you have
    > char > 255. This was a problem in traditional ASP, but should not be a
    > problem in ASP.NET, as strings are Unicode by default. I have not played
    > extensively with MySQL, so I cannot be completely sure, but I have done
    > extensive work with encryption in other databases, requiring no need to pull
    > as binary.
    >
    > I would try pulling the string out straight rather than running from string
    > to byte[] and back to Unicode string.
    >
    > --
    > Gregory A. Beamer
    > MVP, MCP: +I, SE, SD, DBA
    >
    > *************************************************
    > | Think outside the box!
    > |
    > *************************************************"ist" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Hi,

    >
    > > I am trying to get (and transfer over ASP.NET) some encrypted data
    > > from some MySQL fields. Since the data contains many unicode
    > > characters, I tried to get the data as a series of ASCII values,
    > > transfer those numeric values over ASP.NET. I had no problem doing
    > > this on my local computer, by getting the field with "cast(field as
    > > BINARY)" so that on ASP.NET I have a byte[] array.Then send every
    > > field of array over ASP.Net.

    >
    > > However when I upload application to remote server, "cast(field as
    > > BINARY)" returns field data as String type. I have tried many ways to
    > > convert this string data to byte array, however data always become
    > > corrupted. So I have to get data as a byte array directly from MySQL.

    >
    > > As I've said, I had no problem doing this on my local computer,
    > > however, on my local computer I was connecting to same computer using
    > > same driver (MySQL Odbc 3.51), so when I upload the ASP.NET page to
    > > remote server, ONLY thing that is changing is location and -maybe-
    > > ASP.NET version (I am sure both are ASP.NET 2 , maybe different
    > > builds)

    >
    > > So, the bottom line is: I am trying to get MySQL data as byte[] type,
    > > on local web server I have no problem, on remote web server
    > > (connecting to SAME MySQL Server) I get data as String, instead of
    > > Byte[]. How can I achieve same result on remote server?- Alýntýyý gizle -

    >
    > - Alýntýyý göster -
     
    ist, Mar 7, 2008
    #3
  4. Glad you found an answer that works. :)

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    *************************************************
    | Think outside the box!
    |
    *************************************************
    "ist" <> wrote in message
    news:...
    Hi,
    I've 'played' with some MySQL connection properties (Character set,
    collation etc.), and converted String data to byte array at ASP.NET
    side ('played' here with some combinations too) and got a good result
    for now. Thanks..



    On 6 Mart, 16:44, "Cowboy \(Gregory A. Beamer\)"
    <> wrote:
    > First, let's step back. You are using encrypted data, which means you have
    > char > 255. This was a problem in traditional ASP, but should not be a
    > problem in ASP.NET, as strings are Unicode by default. I have not played
    > extensively with MySQL, so I cannot be completely sure, but I have done
    > extensive work with encryption in other databases, requiring no need to
    > pull
    > as binary.
    >
    > I would try pulling the string out straight rather than running from
    > string
    > to byte[] and back to Unicode string.
    >
    > --
    > Gregory A. Beamer
    > MVP, MCP: +I, SE, SD, DBA
    >
    > *************************************************
    > | Think outside the box!
    > |
    > *************************************************"ist" <>
    > wrote in message
    >
    > news:...
    >
    >
    >
    > > Hi,

    >
    > > I am trying to get (and transfer over ASP.NET) some encrypted data
    > > from some MySQL fields. Since the data contains many unicode
    > > characters, I tried to get the data as a series of ASCII values,
    > > transfer those numeric values over ASP.NET. I had no problem doing
    > > this on my local computer, by getting the field with "cast(field as
    > > BINARY)" so that on ASP.NET I have a byte[] array.Then send every
    > > field of array over ASP.Net.

    >
    > > However when I upload application to remote server, "cast(field as
    > > BINARY)" returns field data as String type. I have tried many ways to
    > > convert this string data to byte array, however data always become
    > > corrupted. So I have to get data as a byte array directly from MySQL.

    >
    > > As I've said, I had no problem doing this on my local computer,
    > > however, on my local computer I was connecting to same computer using
    > > same driver (MySQL Odbc 3.51), so when I upload the ASP.NET page to
    > > remote server, ONLY thing that is changing is location and -maybe-
    > > ASP.NET version (I am sure both are ASP.NET 2 , maybe different
    > > builds)

    >
    > > So, the bottom line is: I am trying to get MySQL data as byte[] type,
    > > on local web server I have no problem, on remote web server
    > > (connecting to SAME MySQL Server) I get data as String, instead of
    > > Byte[]. How can I achieve same result on remote server?- Alýntýyý
    > > gizle -

    >
    > - Alýntýyý göster -
     
    Cowboy \(Gregory A. Beamer\), Mar 7, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. crash.test.dummy
    Replies:
    1
    Views:
    993
    Knute Johnson
    Feb 17, 2006
  2. Guest
    Replies:
    2
    Views:
    10,995
    John Harrison
    Jul 26, 2004
  3. Replies:
    20
    Views:
    9,948
    licebmi
    Sep 7, 2009
  4. MSG

    to cast or not to cast malloc ?

    MSG, Feb 6, 2004, in forum: C Programming
    Replies:
    38
    Views:
    1,119
    Dan Pop
    Feb 10, 2004
  5. EvilRix
    Replies:
    8
    Views:
    679
    Martin Dickopp
    Feb 14, 2004
Loading...

Share This Page