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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:32:09+00:00 2026-05-21T07:32:09+00:00

In my MySql i am having my data field as longblob i would like

  • 0

In my MySql i am having my data field as longblob i would like to get the content in that file so i have written my code as follows

This is what i am doing before inserting

  string filePath = Server.MapPath("AchTemplates/genACH.txt");
    string filename = Path.GetFileName(filePath);
    FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
    BinaryReader br = new BinaryReader(fs);
    Byte[] bytes = br.ReadBytes((Int32)fs.Length);
    br.Close();
    fs.Close();

    string strQuery = "insert into tblFiles(FName,FData) values (@_FName, @_FData)";
    MySqlCommand cmd = new MySqlCommand(strQuery);
    cmd.Parameters.Add("@_FName", MySqlDbType.VarChar).Value = filename;
    cmd.Parameters.Add("@_FData", MySqlDbType.LongBlob).Value = bytes;
    InsertUpdateData(cmd);

//Get Data

private void download(DataTable dt)
{
    Byte[] bytes = (Byte[])dt.Rows[0]["FData"];
    Response.Buffer = true;
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = dt.Rows[0]["ContentType"].ToString();
    Response.AddHeader("content-disposition", "attachment;filename="
    + dt.Rows[0]["Name"].ToString());
    Response.BinaryWrite(bytes);
    Response.Flush();
    Response.End();
}

But i am getting the content as system.string[] why it is happening can any one tell

  • 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-05-21T07:32:10+00:00Added an answer on May 21, 2026 at 7:32 am

    if dt.Rows[0]["FData"] is coming as a string (it is just plain text), use

    byte[] bytes = Encoding.UTF8.GetBytes(dt.Rows[0]["FData"]);
    

    If the data is not plain text and binary stored as string (and not base64 encoded), you are in trouble my friend.


    UPDATE

    According to MySql documentation, it seems you should be using LONGBLOB and not LONGTEXT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using mysql Db. I having a field like current_date in date data
Hi am having a query in mysql as follows show tables like 'stud%' ,
I have a php page that pulls data from a mysql database based on
I have a Django app that uses MySQL as a backend. I'm having difficulties
I'm having a 'mare trying to get some simple data from my MySQL database.
I have written a stand-alone script that stores dates (Date type field) in a
I'm having some trouble with MySql right now. I have an query that works
I am fetching some data having UTF8 collation ( utf8_unicode_ci ) from a MySQL
I am having a basic mysql stored procedure for inserting user data along with
I'm trying to move some Excel-Data to MySQL, but having troubles with encoding. What

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.