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 8262259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:42:14+00:00 2026-06-08T03:42:14+00:00

i have a zip file stored in a table by a third party application

  • 0

i have a zip file stored in a table by a third party application which i have no control over. I do however have access to the MySQL DB.

What i want to do is do a SELECT statement to retrieve a blob field and copy this record into another table. But on the other side, i do see the blob field on the far side but it is not a zip file, its a text file that says System.Byte[] and thats it – anyone any ideas on what is causing this and how to fix it?

heres what i have below – again any help greatly appreciated 🙂

OdbcCommand broadcastSelect = new OdbcCommand("select * from exchange where status='1' and type='UPDATE'", cloud);
                OdbcDataReader DbReader = Select.ExecuteReader();
                int fCount = DbReader.FieldCount;
                String type = "";
                String filename = "";
                byte[] data = null;
                int status = 0;

                while (DbReader.Read())
                {
                    if (DbReader.IsDBNull(0))
                    {
                        type = "BLANK";
                    }
                    else
                    {
                        type = (string)DbReader[0];
                    }
                    if (DbReader.IsDBNull(1))
                    {
                        filename = "BLANK";
                    }
                    else
                    {
                        filename = (string)DbReader[1];
                    }
                    if (DbReader.IsDBNull(2))
                    {
                        data = new byte[1];
                    }
                    else
                    {
                        data = (byte[])DbReader[2];
                    }
                    if (DbReader.IsDBNull(3))
                    {
                        status = 0;
                    }
                    else
                    {
                        status = (int)DbReader[3];
                    }

                    OdbcCommand Copy = new OdbcCommand("INSERT INTO exchange(type,filename,data,status) VALUES('" + type + "','" + filename + "','"
                        + data + "','" + status + "')", local);
                    Copy.ExecuteNonQuery();

                }
  • 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-08T03:42:16+00:00Added an answer on June 8, 2026 at 3:42 am

    use sql parameter for inserting the binary data.

    OdbcParameter param = new OdbcParameter("@file", SqlDbType.Binary); 
    

    —Updated
    I hope below given code will be helpful to you.

     OdbcCommand broadcastSelect = new OdbcCommand("select * from exchange where status='1' and type='UPDATE'", cloud);
            OdbcDataReader DbReader = Select.ExecuteReader();
            int fCount = DbReader.FieldCount;
            String type = "";
            String filename = "";
            byte[] data = null;
            int status = 0;
            OdbcParameter param = null;
            while (DbReader.Read())
            {
                if (DbReader.IsDBNull(0))
                {
                    type = "BLANK";
                }
                else
                {
                    type = (string)DbReader[0];
                }
                if (DbReader.IsDBNull(1))
                {
                    filename = "BLANK";
                }
                else
                {
                    filename = (string)DbReader[1];
                }
                if (DbReader.IsDBNull(2))
                {
                    param = new OdbcParameter("@file", SqlDbType.Binary);
                    param.DbType = DbType.Binary;
                    param.Value = new byte[1];                
                    command.Parameters.Add(param); 
                }
                else
                {
                    param = new OdbcParameter("@file", SqlDbType.Binary);
                    param.DbType = DbType.Binary;
                    param.Value = (byte[])dbReader[2];
                    param.Size = ((byte[])dbReader[2]).Length; 
                    command.Parameters.Add(param); 
                }
                if (DbReader.IsDBNull(3))
                {
                    status = 0;
                }
                else
                {
                    status = (int)DbReader[3];
                }
    
                OdbcCommand Copy = new OdbcCommand("INSERT INTO exchange(type,filename,data,status) VALUES('" + type + "','" + filename + "',@file,'" + status + "')", local);
                Copy.ExecuteNonQuery();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have .zip file which contain csv data. I am reading .zip file using
I have always wondered about this. So many application setups have a zip file
In one of my git projects, I have a zip file which bundles a
I have created password protected zip file which has xls file with the help
I have a perl script URL which gives me a ZIP file, it processes
For example, I want to zip a file stored in /Users/me/Desktop/image.jpg I made this
I have stored my zip file in blob storage . I already read archive
I have a zip file containing a folder and inside the folder I have
I have a zip file compressed using Ionic zip . Before extracting I need
I have found that creating a zip file using the Zip task provided by

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.