String to Linq.Byte and Linq.Byte to String convertion?


I have a field in my database as image type. I am using Linq to read/insert records.

I am having little hard time inserting text(string) into the image field and then converting back to string.

Do you have any suggestions?


Thanks in advance,


1/22/2009 3:31:29 PM 91979 articles. 4 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 2
Get it on Google Play
Get it on Apple App Store

 The below example shows how to convert Linq Binary to byte

 If Not String.IsNullOrEmpty(HttpContext.Current.Request.QueryString("imageID")) Then
Dim imageID = HttpContext.Current.Request.QueryString("imageID")
Dim db As New AuctionsDataContext
Dim result = From img In db.Images _
Where img.imageID = imageID _
Select img.image

HttpContext.Current.Response.BinaryWrite(CType(result.First.ToArray, Byte()))

 and next you can convert bytearray to string like this

public static string ByteArrayToString(byte[] ba)
string hex = BitConverter.ToString(ba);
return hex.Replace("-","");



Please mark the answer if it helped you
1/22/2009 3:39:03 PM


sorry, i copied wrong...its


1/22/2009 3:58:47 PM

Similar Artilces:

RSA Encryption
Here is my goal:1. Take a string2. Encrypt it 3. Pass it as a parameter in the QueryString4. Decrypt it The value starts as a string, then is converted to a byte[] and then encrypted.  The resulting byte[] is converted to a string and send as a parameter.  The recieving page decrypts the string (creates a byte[], decrypts to a new byte[], and the value is finally parsed for its values) I am using with a small modification t...

convert byte[] to String and string to byte[] note encoding and decoding required....
hi all,        As the subject, can I have solution ofr the same.......  e'i Convert byte[] into string and strting into byte[] , can i have teh sample page.        Thanks & Regards,Murthy.          System.Text.Encoding.Unicode.GetString(ByteArray);//Byte Array to String             System.Text.Encoding.Unicode.GetBytes(String);//String to Byte ArrayWe All move to our original place.Don't forget.Imran Baloch thanks for...

How to append string to Response.OutputStream after string converted to byte array
Hi, I am trying to append string to Response.OutputStream property in PostRequestHandlerExecute event handler inside custom httpmodule. The goal of this implementation is to append string to output stream after the page is rendered when the response object is still held on the server. The pseudo code I wrote is the following: private void PostRequestHandlerExecute(object sender, EventArgs e) { HttpApplication application = ( HttpApplication ) sender; HttpContext context = application.Context;   string s = "This is test!"; byte[] buffer = Encoding.ASCII.GetByt...

Converting bytes to string
Hi guys,I'm currently trying to insert image into my SQL db.  I have tried a number of methods that were posted online, and so far with no luck.My current code reads:                     Dim conn As New Data.SqlClient.SqlConnection()                    conn.ConnectionString = ConfigurationManager.ConnectionStrings("MainDBConnection").ToString        &nbs...

Am I correct in thinking that the only way to get ord() to return a value over 256 is to send the character as a Unicode string instead of a byte string?
In other words, is there any character that will make ord() return over = 256 when passed in as a byte string? For example, note the differences in output between a unicode string and = a byte string regarding character 257, as a unicode string it is 257, as = a byte string it is 196. $ perl -C6 -le 'print "Character 257 info:";print "\tunicode \\x{} = notation: " . sprintf(q{\x{%x}}, 257);print "\tOutput as Unicode string = \x{101}";print "\tunicode string \\x{} notation ord(): " . = ord("\x{101}");print "\tbyte string gr...

string to byte array
Hi all, I'm currently building a small app which uses 3DES encryption, it works all nicely, but would like to do a bit a fix upcurrently the code behind has the code as followDim key As Byte() = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22.2, 23, 24}and the web.config is as follows    <appSettings>    <add key="key" value="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22.2, 23, 24"/>    </appSettings> I am trying to call the values {1, 2 ,...

How do I convert string to a byte array?
[see also] Working with an old OLE object for TCP comm, and the unicode vs ANSI charset change at PB 10 seems to be causing issues. BUT! the old object avoids "'wide' to ANSI" conversion and just sends what it's handed if it's handed a BYTE Array. However, getting there from a string seems to involve conversion to and parsing from a Blob, something that I'm fumbling. Some help on this conversion process would be appreciated. Convert the string to ...

String and String[]
What will be the advantage of using myString: String[10] over myString: String Man wrote: > What will be the advantage of using > myString: String[10] > over > myString: String "String[10]" is a fixed-length, statically allocated, Ansi-based ShortString. "String" is a dynamic-length, dynamically allocated, reference counted, Ansi-based or Unicode-based (depening on Delphi version) Long string. Unless you absolutely need the static, fixed length nature of ShortString, such as in records that interact with external systems, you should stay ...

string to string[]
Hi, I've got this code : string[] Params; string SQL = "SELECT * FROM T_MANAGEMENT_PAGES"; SqlCommand myCommand = new SqlCommand(SQL, myConnection); myConnection.Open(); SqlDataReader myReader = myCommand.ExecuteReader(); try { while (myReader.Read()) { Params_Type = myReader.GetValue(0).ToString(); } } catch { } finally { } myReader.Close(); My problem is to obtain Params_Type. But each time, it says : "impossible to convert '[object]' in 'string[]' &quo...

String and string?
Hi guys, I was wondering the difference between small letter string type and a capital letter String type. Does anyone know about this? Highly appreciate for your answers! Thankz! The "proper" version is String, as it references the System.String class of the .NET Framework Class Library. The ability to use string is provided by C#, where it is an alias to String. Similarly, the "proper" version of an integer is Int32, as it references System.Int32.  The ability to use int is provided by C#, and the ability to use Integer is provided by VB.NET, and both int and Integer are aliases...

string and string[]
hello, whats the difference here between string and string[] thanks "string" denotes an item of type String "string[]" denotes an array of type String itemsThanks, EdMicrosoft MVP - ASP/ASP.NET Gracia mon ami...

string() = string()
this code does not work (not instance of object) Dim Items(), Other() As String Items = New String() {"A","B","C"} Other = New String() {} Other = Items how can I get all the values ? angiras Hi, If I understand your requirement correctly, this should do it Dim Items() As String = {"A", "B", "C"} Dim Other(Items.Length - 1) As String Items.CopyTo(Other, 0) To more closely match you code above, but this will be less efficient Dim Items(), Other() As String ...

How to get a LINQ entity from a string representation
HiI am stuck with a problem. My client script is sending me a database table name as string. Now in my C# code i need that table object. Say for example:my javascript sending me the table name products as a string and i need to get  the Product object of northwind database. I need all the columns and their corresponding data type.Is it possible by LINQ?   Please dont forget to click "Mark as Answer" on the reply that helped to solve your problem. Okay I got it. Its Reflection that was my savior. Just sharing my solution with you 1 protected void LinqEntityO...

byte to string
Hi all, How do I represent: Dim HashedDataBytes As Byte() Dim Encoder As New UTF8Encoding() Dim md5Hasher As New MD5CryptoServiceProvider() HashedDataBytes = md5Hasher.ComputeHash(Encoder.GetBytes(aStr)) HashedDataBytes as a String? Cheers, D. Convert.ToBase64String(HashedDataBytes) Here is the function I use to create MD5 hashes, if that is what you are trying to do Public Shared Function createMD5(ByVal SourceText As String) As String 'Create an encoding object to ensure the encoding standard for the source text Dim Ue As New UnicodeE...

Web resources about - String to Linq.Byte and Linq.Byte to String convertion? -

Tony Williams (@TBone8) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Talk:Brazilian real - Wikipedia, the free encyclopedia
This article is within the scope of WikiProject Brazil , a collaborative effort to improve the coverage of Brazil and Brazil-related topics on ...

Biomass Energy (木薯干) - Solar panel in Sydney - Solar Inverters - Mounting Racks
We have product for Solar power, Wind Turbine, Biomass, Battery, which your requirements The cassava to ethanol convertion has really changed ...

List of FAQ - AbiWiki
List of FAQ From AbiWiki (Redirected from FAQ ) Jump to: navigation , search AbiWord Frequently Asked Questions Contents 1 User FAQ 1.1 General ...

Highways of the State of Illinois
Sponsored by Roads of the Mid-South & West > Illinois Welcome Sign on WB IL St Rt 114 at the Illinois/Indiana State Line near Momence...Illinois ...

Leroy Burgess: Sweet expectations
Pete Lewis speaks to New York soul/dance legend Leroy Burgess, to discuss the prolific veteran singer/songwriter/producer’s new LP ‘Throwback ...

The Way to Build HTML5 Video Blog
Someday ago, we have discussed how to get more views with HTML 5 video in previous post. Now, we are going to make this tutorial which tells ...

carriole remorque à vélo deux plus deux
449.00 Euros = 511.86 US $', LEFT, CAPTION, 'Convertion Devise', WIDTH, 200, FGCOLOR, 'gray', BGCOLOR, '#0000FE', TEXTCOLOR, 'white')" onMouseOut="nd()"> ...

Concept Feedback - Search for Web Design, Marketing, and Usability Reviews
Search for inspiration and reviews on websites, landing pages, newsletters, logos, wireframes, mockups, advertisements, illustrations, layouts ...

Resources last updated: 12/21/2015 11:20:19 AM