David W
David W

Reputation: 1941

Uploading a byte array to MYSQL

I have a file I converted into one long string. I want to take that string, convert it to a array of bytes then upload it to my database. However, when i run my code, it shows up in the database as NULL;

Here's my code:

SQL.UploadFile(Encoding.ASCII.GetBytes(FBX), txt_Name.Text);

        public void UploadFile(byte[] value, string Where)
    {

        const string SQL = "UPDATE itemmodel SET modelFile='@File' WHERE modelName='@Name'";
        MySqlCommand cmd = new MySqlCommand(SQL, MySqlCon);
        cmd.Parameters.AddWithValue("@File", value);
        cmd.Parameters.AddWithValue("@Name", Where);
        MySqlCon.Open();
        cmd.ExecuteNonQuery();
        MySqlCon.Close();

    }

Upvotes: 0

Views: 2779

Answers (1)

competent_tech
competent_tech

Reputation: 44971

I really don't think that you want the quotes around the parameters in the SQL:

const string SQL = "UPDATE itemmodel SET modelFile=@File WHERE modelName=@Name";

Certainly not around @File.

Upvotes: 2

Related Questions