Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Convert string to byte array

Posted on 2004-08-25
14
Medium Priority
?
229 Views
Last Modified: 2010-08-05
title says it all

also, if you are aware, can someone post how i would insert a byte array into a database using oracleclient
0
Comment
Question by:lmpsteelwire
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
14 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11893436
get string from byte array ...
Dim myArray As Byte() = {50, 70, 71}
Dim s2 As String
s2 = System.Text.Encoding.ASCII.GetString(myArray)

GetBytes() will return a byte array for a string
Dim myArray As Byte()
Dim s2 As String = "hello"
myArray = System.Text.Encoding.ASCII.GetBytes(s2)


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextencodingclassasciitopic.asp

depending on your data you may want to use the UTF encoding object ... the help explains why you may want to do this.
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1000 total points
ID: 11893458
0
 
LVL 14

Expert Comment

by:ptakja
ID: 11893522
Dim bytValue As Byte()
bytValue = Convert.FromBase64String(strYourString)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11893583
that will only work if you base64 encode the data on the way in ...
0
 
LVL 2

Author Comment

by:lmpsteelwire
ID: 11893593
ya, its a BLOB, which is just a paragraph of text
0
 
LVL 4

Expert Comment

by:Daniellus83
ID: 11893703
I am just gonna you the answer to the 'title'-question:

Code to convert a string into a byte array:

    Dim YourString as String
    Dim ByteArray(1) As Byte  'Just give it a dimension

    Sub CopyIntoByteArray()

        Dim i, intArraySize  As Integer
       
        intArraySize = CInt((Len(YourString) + 1) / 2) - 1
        ReDim ByteArray(intArraySize)

        For i = 0 To intArraySize
            ByteArray(i) = "&H" & Mid(YourString , i * 2 + 1, 2)
        Next i

    End Sub

...this should do the trick...

Try it and maybe you like it!
0
 
LVL 2

Author Comment

by:lmpsteelwire
ID: 11893724
hmm...ok i made my oraclelob object, and used .write...but how do i set it up to go a row, right column, of right table...i think somewhere i got lost here.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11893755
there is an example on the link.
0
 
LVL 2

Author Comment

by:lmpsteelwire
ID: 11893804
duh. sorry, it was a long night. thanks greg
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11893863
coffee or beer ? :)

Glad to help.

Cheers,

Greg
0
 
LVL 2

Author Comment

by:lmpsteelwire
ID: 11893957
keg between about 5 of us

sure is great to be back to work on a wednesday morning.
0
 
LVL 2

Author Comment

by:lmpsteelwire
ID: 11896482
in the c# example, they use: CreateTempLob(cmd, BLOB.LobType)

and i definitely cant use that in vb.net...do you know the equivilant?
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11896970
actually I think thats just a little function they wrote and forgot to copy into the example that would just instantiate a lob object with the command object and blobtype.
0
 
LVL 2

Author Comment

by:lmpsteelwire
ID: 11897156
excellent
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question