Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. LONGTEXT not accepting large text!

LONGTEXT not accepting large text!

Scheduled Pinned Locked Moved Database
htmlcsscomquestionannouncement
13 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P PIEBALDconsult

    What database system?

    J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #3

    sorry, forgot to mention it.. It's MySQL

    Technology News @ www.JassimRahma.com

    1 Reply Last reply
    0
    • J Jassim Rahma

      Hi, I am trying to save an html text which is less than 1MB using LONGTEXT datatype but getting:

      Data too long for column

      what could be the reason?! Thanks, Jassim

      Technology News @ www.JassimRahma.com

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #4

      Are you sure the error relates to your LONGTEXT column? Assuming this is MySQL, the column should be able to store up to 4,294,967,295 characters.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      J 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Are you sure the error relates to your LONGTEXT column? Assuming this is MySQL, the column should be able to store up to 4,294,967,295 characters.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        J Offline
        J Offline
        Jassim Rahma
        wrote on last edited by
        #5

        what else it could be? I tried saving a very small image and it was find but when I save larger image in the html (less than 1 mb image) I'll get that error. this is the complete error:

        MySql.Data.MySqlClient.MySqlException was unhandled
        HResult=-2147467259
        Message=Data too long for column 'param_message' at row 2
        Source=MySql.Data
        ErrorCode=-2147467259
        Number=1406
        StackTrace:
        at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
        at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
        at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
        at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
        at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
        at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
        at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
        at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
        at BizCards.frmMessage.btnSave_ItemClick(Object sender, ItemClickEventArgs e) in c:\Users\CakeBoutique\Documents\Visual Studio 2012\Projects\BizCards\BizCards\message.cs:line 100
        at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
        at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
        at DevExpress.XtraBars.BarButtonItem.OnClick(BarItemLink link)
        at DevExpress.XtraBars.BarItemLink.OnLinkClick()
        at DevExpress.XtraBars.BarButtonItemLink.OnLinkClick()
        at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
        at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
        at DevExpress.XtraBars.BarItemLink.OnLinkActionCore(BarLinkAction action, Object actionArgs)
        at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
        at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
        at DevExpress.XtraBars.Controls.CustomLinksControl.OnMouseUp(MouseEventArgs e)
        at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
        at System.Windows.Forms.Control.WndProc(Message& m)
        at DevExpress.XtraBars.Controls.CustomControl.WndProc(Message& msg)
        at DevExpress.XtraBars.Controls.DockedBarControl.WndProc(Message& msg)
        at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

        Richard DeemingR 1 Reply Last reply
        0
        • J Jassim Rahma

          what else it could be? I tried saving a very small image and it was find but when I save larger image in the html (less than 1 mb image) I'll get that error. this is the complete error:

          MySql.Data.MySqlClient.MySqlException was unhandled
          HResult=-2147467259
          Message=Data too long for column 'param_message' at row 2
          Source=MySql.Data
          ErrorCode=-2147467259
          Number=1406
          StackTrace:
          at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
          at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
          at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
          at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
          at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
          at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
          at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
          at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
          at BizCards.frmMessage.btnSave_ItemClick(Object sender, ItemClickEventArgs e) in c:\Users\CakeBoutique\Documents\Visual Studio 2012\Projects\BizCards\BizCards\message.cs:line 100
          at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
          at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
          at DevExpress.XtraBars.BarButtonItem.OnClick(BarItemLink link)
          at DevExpress.XtraBars.BarItemLink.OnLinkClick()
          at DevExpress.XtraBars.BarButtonItemLink.OnLinkClick()
          at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
          at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
          at DevExpress.XtraBars.BarItemLink.OnLinkActionCore(BarLinkAction action, Object actionArgs)
          at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
          at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
          at DevExpress.XtraBars.Controls.CustomLinksControl.OnMouseUp(MouseEventArgs e)
          at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
          at System.Windows.Forms.Control.WndProc(Message& m)
          at DevExpress.XtraBars.Controls.CustomControl.WndProc(Message& msg)
          at DevExpress.XtraBars.Controls.DockedBarControl.WndProc(Message& msg)
          at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #6

          How are you saving an image in an HTML string - embedded as a data URI, or something else?


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          J 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            How are you saving an image in an HTML string - embedded as a data URI, or something else?


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            J Offline
            J Offline
            Jassim Rahma
            wrote on last edited by
            #7

            base64 string like this:

            ![](data:image/png;base64,.........
            </pre>
            <div class=)

            Technology News @ www.JassimRahma.com

            Richard DeemingR 1 Reply Last reply
            0
            • J Jassim Rahma

              base64 string like this:

              ![](data:image/png;base64,.........
              </pre>
              <div class=)

              Technology News @ www.JassimRahma.com

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #8

              OK, that shouldn't significantly increase the size. The Base64 encoded string shouldn't be more than 1/3 larger than the raw bytes. So param_message is definitely the parameter you're using to pass the HTML? Can you post the code you're using to create the command object and its parameters?


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              J 1 Reply Last reply
              0
              • Richard DeemingR Richard Deeming

                OK, that shouldn't significantly increase the size. The Base64 encoded string shouldn't be more than 1/3 larger than the raw bytes. So param_message is definitely the parameter you're using to pass the HTML? Can you post the code you're using to create the command object and its parameters?


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                J Offline
                J Offline
                Jassim Rahma
                wrote on last edited by
                #9

                this is the code:

                this.Cursor = Cursors.WaitCursor;

                // save the contact;
                sql_connection = new MySqlConnection("my_connection");
                sql_connection.Open();

                sql_command = new MySqlCommand("sp_save_message", sql_connection);

                sql_command.CommandType = CommandType.StoredProcedure;
                sql_command.CommandTimeout = Convert.ToInt32(sql_command_timeout);

                sql_command.Parameters.AddWithValue("param_message_id", message_id).MySqlDbType = MySqlDbType.Int32;
                sql_command.Parameters.AddWithValue("param_message", txtMessage.HtmlText).MySqlDbType = MySqlDbType.LongText;

                int result_rows = sql_command.ExecuteNonQuery();

                this.DialogResult = System.Windows.Forms.DialogResult.OK;

                Technology News @ www.JassimRahma.com

                Richard DeemingR 1 Reply Last reply
                0
                • J Jassim Rahma

                  this is the code:

                  this.Cursor = Cursors.WaitCursor;

                  // save the contact;
                  sql_connection = new MySqlConnection("my_connection");
                  sql_connection.Open();

                  sql_command = new MySqlCommand("sp_save_message", sql_connection);

                  sql_command.CommandType = CommandType.StoredProcedure;
                  sql_command.CommandTimeout = Convert.ToInt32(sql_command_timeout);

                  sql_command.Parameters.AddWithValue("param_message_id", message_id).MySqlDbType = MySqlDbType.Int32;
                  sql_command.Parameters.AddWithValue("param_message", txtMessage.HtmlText).MySqlDbType = MySqlDbType.LongText;

                  int result_rows = sql_command.ExecuteNonQuery();

                  this.DialogResult = System.Windows.Forms.DialogResult.OK;

                  Technology News @ www.JassimRahma.com

                  Richard DeemingR Offline
                  Richard DeemingR Offline
                  Richard Deeming
                  wrote on last edited by
                  #10

                  OK, nothing obviously wrong there. How about the stored procedure?


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                  J 1 Reply Last reply
                  0
                  • Richard DeemingR Richard Deeming

                    OK, nothing obviously wrong there. How about the stored procedure?


                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                    J Offline
                    J Offline
                    Jassim Rahma
                    wrote on last edited by
                    #11

                    you are the man :) I missed the longtext in my sp. It was text only. Now I have one more and last :) problem. How can I solve:

                    Quote:

                    Packets larger than max_allowed_packet are not allowed.

                    for using large text?

                    Technology News @ www.JassimRahma.com

                    Richard DeemingR 1 Reply Last reply
                    0
                    • J Jassim Rahma

                      you are the man :) I missed the longtext in my sp. It was text only. Now I have one more and last :) problem. How can I solve:

                      Quote:

                      Packets larger than max_allowed_packet are not allowed.

                      for using large text?

                      Technology News @ www.JassimRahma.com

                      Richard DeemingR Offline
                      Richard DeemingR Offline
                      Richard Deeming
                      wrote on last edited by
                      #12

                      It looks like you need to change the configuration of MySQL: http://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html[^]

                      [mysqld]
                      max_allowed_packet=1024M

                      There doesn't seem to be any other way to fix that error.


                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                      J 1 Reply Last reply
                      0
                      • Richard DeemingR Richard Deeming

                        It looks like you need to change the configuration of MySQL: http://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html[^]

                        [mysqld]
                        max_allowed_packet=1024M

                        There doesn't seem to be any other way to fix that error.


                        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                        J Offline
                        J Offline
                        Jassim Rahma
                        wrote on last edited by
                        #13

                        Thanks :) Thanks :)

                        Technology News @ www.JassimRahma.com

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups