Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:56:20+00:00 2026-06-12T09:56:20+00:00

I am trying to put some data to a MSSQL Database, which I created

  • 0

I am trying to put some data to a MSSQL Database, which I created with Visual Basic. When I am executing the code, I get the following errors:

Error   21  Cannot implicitly convert type 'string' to 'byte[]' c:\users\hussein\documents\visual studio 2012\Projects\WebApplication2\WebApplication2\defualt.aspx.cs  32  33  WebApplication2
Error   22  Cannot implicitly convert type 'string' to 'byte[]' c:\users\hussein\documents\visual studio 2012\Projects\WebApplication2\WebApplication2\defualt.aspx.cs  33  32  WebApplication2
Error   23  Cannot implicitly convert type 'string' to 'byte[]' c:\users\hussein\documents\visual studio 2012\Projects\WebApplication2\WebApplication2\defualt.aspx.cs  34  34  WebApplication2
Error   24  Cannot implicitly convert type 'string' to 'byte[]' c:\users\hussein\documents\visual studio 2012\Projects\WebApplication2\WebApplication2\defualt.aspx.cs  35  34  WebApplication2

Here is my code, I tried to convert the string to byte[], but I have binary text in my database.

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Linq;
using System.Data.Linq;

namespace WebApplication2
{
    public partial class defualt : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Unnamed5_Click(object sender, EventArgs e)
        {
            if ((TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == ""))
            {
                Label1.Text = "<h3>- Du måste fylla i alla fält, brorsan</h3>";
            }
            else
            {
                DatabaseEntities db = new DatabaseEntities();
                var nyMedlem = new medlemar();
                nyMedlem.namn = TextBox1.Text;
                nyMedlem.anv = TextBox2.Text;
                nyMedlem.losen = TextBox3.Text;
                nyMedlem.epost = TextBox4.Text;
                db.medlemar.Add(nyMedlem);
                db.SaveChanges();
                Label1.Text = "<h3>- Nu är du medlem</h3>";
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:56:21+00:00Added an answer on June 12, 2026 at 9:56 am

    You are probably saving 4 text fields into a data base field which is of the format byte[], hence you are getting the conversion 4 times.

    Try this : It requires a change in medlemar class.

    string x = TextBox1.Text;
    byte[] y = System.Text.Encoding.UTF8.GetBytes(x);
    
    nyMedlem.(something of data type byte[]) = y;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to put some geolocation data from Google Maps into a database. But
trying to retrieve some data from the database and put in into my form.
i'm trying to insert some data on a database using this code: -(void)insertLocationOnDatabase:(LocationType *)aLocation
I'm looking for some assistance with some code. I'm trying to put this to
I am trying to put some JSON formatted data via Ajax with jQuery to
ok, I'm trying to figure out how to put some data into an inline
i am trying escape some data before it goes into my database, but i
Im trying to retrieve some data from JSON object which holds location information such
Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The
I am trying to put a button which will be displayed along with some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.