Menu

error when saving

2004-06-19
2004-06-24
  • Nobody/Anonymous

    Hi,

    I was previously using the 0.1.3 version, and when i saved an object, immediately after, the origModDate would be set to blankDate=12:00:00.  So I downloaded the latest version 0.1.3 to see if this would fix the problem, and now the save function throws an error:

    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1:43:43 PM, ModifiedDate=6/19/2004 4:44:43 PM, promoid=20, titl

    I have read the post about changing the param value from ? to @p in CMySQLDatabase.vb, but the version i downloaded has that fix.  I have no idea what the problem is, can you please help on this situation, and shed any light on wether the latest version solved the OrgModDate problem.

    Thanks

    bo

     
    • Nobody/Anonymous

      Hi, just a correction to my last post, what i meant by latest version was 0.1.8 not 0.1.3

      thanks

       
    • Richard Banks

      Richard Banks - 2004-06-20

      Hi Bo,

      I've just rechecked and the modified date is working well (I have MySQL 4.0.20a using ByteFX 0.76).

      Can you post your server version details and the debug info and SQL statement that is displayed in the visual studio output window just before the exception is thrown and your .net code where the error occurs.

      The debug output will look something like this

      BEGIN TRANSACTION
      Saving object CPerson
      @p1: 75aab711ed6b40dc8c26708ddd1c6c79
      @p2: testing
      @p3: 21/06/2004 9:40:06 AM
      @p4: 21/06/2004 9:39:05 AM
      @p5: 21/06/2004 9:40:06 AM
      UPDATE Person SET guid=@p1, person_name=@p2, create_date=@p3, CreatedDate=@p4, ModifiedDate=@p5 WHERE Person.guid = '75aab711ed6b40dc8c26708ddd1c6c79' AND Person.CreatedDate = '2004-06-21 09:39:05' AND Person.ModifiedDate = '2004-06-21 09:39:34'

      - Richard.

       
    • Nobody/Anonymous

      Hi Richard,

      My sql server version is 4.0.16, and my Bytefx version is 0.76, which I just installed thinking that would fix the problem, but i still get the same error when I save().  So, the sql statement in the output window is :

      BEGIN TRANSACTION
      Saving object CPromotion
      <<Reusing existing connection 1>>
      Nested BEGIN TRANSACTION - not actually called
      Nested COMMIT TRANSACTION - not actually called
      <<Closing connection 2>>
      @p1: 000000780001
      @p2: 6/22/2004 2:35:12 PM
      @p3: NULL
      @p4: 29
      @p5: asfasf
      @p6: afdasf asfd a
      @p7: NULL
      @p8: NULL
      @p9: Me
      @p10: stub.log
      @p11: 0
      INSERT INTO promotion (oid, CreatedDate, ModifiedDate, promoid, title, description, price, expirydate, createdby, filename, isactive) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11)
      ROLLBACK TRANSACTION
      <<Closing connection 1>>
      Cache - Delete object with keys:
          1) System.String: 000000780001
      The thread 'Thread EB0' (0xeb0) has exited with code 0 (0x0).

      The debug info is:

      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

      Exception Details: ByteFX.Data.MySqlClient.MySqlException: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '2:35:12 PM, Null, 29, 'asfasf', 'afdasf asfd a', Null, Null, 'M

      vb.net code is:

              Try
                  Dim xmlDoc As CXMLFile
                  m_Promo = New CPromotion()
                  xmlDoc = New CXMLFile(ConfigurationSettings.AppSettings("appfilepath"))
                  m_Promo.PromoID = CType(xmlDoc.getChildInnerText("promoid", "Promotions"), Integer) + 1
                  xmlDoc.EditChild("promoid", CType(m_Promo.PromoID, String), "Promotions")
                  xmlDoc.SaveFile()
                  m_Promo.Title = txtTitle.Text
                  m_Promo.Description = txtDesc.Text
                  m_Promo.FileName = lblImgPath.Text
                  m_Promo.ExpiryDate = cldExpDate.SelectedDate
                  'm_Promo.CreatedBy = getUserName()
                  m_Promo.CreatedBy = "Me"
                  m_Promo.Price = txtPrice.Text
                  'm_Promo.Find(m_Promo)
                  'If Not m_Promo.Persistent Then
                  m_Promo.Save()
                  'm_Promo.Find(m_Promo, False)
                  'bindData()
                  lblMsg.Text = m_Promo.OriginalModifiedDate
                  dt = Session("promotable")
                  ObjectToRow(m_Promo, dt)
                  resetView()
                  'Else
                  '    lblMsg.Text = "Error with promotion ID's, contact Administrator"
                  'End If
                  Dim mfile As File
                  mfile.Move(ConfigurationSettings.AppSettings("TempimgDir") & lblImgPath.Text, ConfigurationSettings.AppSettings("imgDir") & lblImgPath.Text)
              Catch f As FileNotFoundException
                  lblMsg.Text = f.InnerException.Message
              Catch f As Exception
                  'lblMsg.Text = f.Message
                  Throw f
              Finally ....

      Things to make note of:
      this is an asp.net application, so there is no state.  I am forced to create a new instance of a CPersistent object everytime the user posts back to the server.  If i need to retrieve an object that i used previously, i do a find, then i manipulate the object.  Keeping the objects in memory is too costly.  In this instance however, i am just creating a new object to save to db.  When i used the 0.1.3 version, the modified date for a new object being saved was null.  This occurs in 0.1.8 as well, as shown above by @p3, but I did not get an error with the 0.1.3 version, and the save worked fine.  The reason I ventured into the 0.1.8, as I mentioned before was to solve the problem of OrigModDate being blank after a save() operation.  So help on both of these issues would be appreciated.

      Thanks,

      Bo

       
    • Richard Banks

      Richard Banks - 2004-06-22

      Hi Bo,

      Point #1.  New objects won't have a modified date. Modified dates are only set when an existing object is re-saved.  This will be why you don't have an OrigModDate and why NULLs are going in the ModifiedDate field.

      Point #2. The code for the ASP looks good.  What you are doing with the find/update/save sequence is perfectly OK.  I wonder if your date format for you SQL server is different.  I don't think it should matter since a datetime value is passed to the parameter and ByteFX should handle it, but it may be worth checking.

      In any case, can you do the following:

      In the mysql command line run the statement

      INSERT INTO promotion (oid, CreatedDate, ModifiedDate, promoid, title, description, price, expirydate, createdby, filename, isactive) VALUES ('000000780001', '22-06-2004 2:35:12 PM', NULL, 29, 'asfasf', 'asfasf asfd a', NULL, NULL, 'Me', 'stub.log', 0);

      and see if the command completes correctly.  If it doesn't then maybe one of your columns is set incorrectly.

      If that works can you step through the code in CConnection.vb at CMySqlConnection.processStatement().  Check that the parameter types (param.MySqlDbType) match the column types in the database and that the values make sense.

      It seems that the created date field is the one giving you problems.  This should be a DATETIME column.

      I'll wait for your reply.

      - Richard.

       
    • Nobody/Anonymous

      Hi Richard,

      Sorry for the late reply.  I didn't have a chance until now to take a look at it.  The reason an sql error was occuring when i saved with the 0.1.8 version was that my createddate and modifieddate columns were timestamps, and not datetime.  The problem has been solved.  Thanks for your help.

      Bo

       
      • Richard Banks

        Richard Banks - 2004-06-24

        No problems.

        I'm glad it's all working now.

        Richard

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.