Convert/cast string to binary

Posted on 2011-10-13
Last Modified: 2012-05-12
I have a table with fields varbinary (i cant change the column type). I use LINQ and I want to assign the database column to a textbox I do this:

IncomingPatient ip = new IncomingPatient(); //this is the table
//ip.firstname Binary

ip.firstname = first_name.Text
I get this error: Cannot implicitly convert type 'string' to 'System.Data.Linq.Binary'

I've been googling and someone here is saying to change the Binary to Byte[]

How can I do this? do i need to change to Byte[]?
Question by:Camillia
    1 Comment
    LVL 17

    Accepted Solution

    Hello, well, have you tried this?:
    IncomingPatient ip = new IncomingPatient(); //this is the table
    ip.firstname = new System.Data.Linq.Binary(System.Text.Encoding.UTF8.GetBytes(first_name.Text));

    Open in new window


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now