Telerik
Skip Navigation LinksHome / Community / Forums / ASP.NET > Editor > Invalid Precision Value inserting data into Microsoft Access Memo field

Invalid Precision Value inserting data into Microsoft Access Memo field

Feed from this thread
  • Bryan Jones avatar

    Posted on Oct 3, 2006 (permalink)


    I thought I would share a fix with everyone that took a while for me to track down.

    When inserting string data > 255 characters (for example when storing the output from RADEDIT.html) into a Microsoft Access database memo field you will sometimes get the error below

    ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
    Exception Details: System.Data.Odbc.OdbcException: ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value

    I say sometimes as I have some pages using the code below which work fine and others that failed every single time.

    Code that produces the error
    Dim dbconn As New Odbc.OdbcConnection
    dbconn.ConnectionString = Global.bmfdb
    dbconn.Open()
    Dim sqlcmd As New Odbc.OdbcCommand
    Dim da As New Odbc.OdbcDataAdapter
    sqlcmd.Connection = dbconn
    sqlcmd.CommandText = "update tablex set thememofield=? where pageid=?"
    sqlcmd.Parameters.Add("@thememofield", RADEDITpagetext.Html)
    sqlcmd.Parameters.Add("@pageid", viewstate("pageid"))
    sqlcmd.ExecuteNonQuery()
    sqlcmd.Dispose()
    dbconn.Dispose()


    Fixed Code
    Dim dbconn As New Odbc.OdbcConnection
    dbconn.ConnectionString = Global.bmfdb
    dbconn.Open()
    Dim sqlcmd As New Odbc.OdbcCommand
    Dim da As New Odbc.OdbcDataAdapter
    sqlcmd.Connection = dbconn
    sqlcmd.CommandText = "update tablex set thememofield=? where pageid=?"
    Dim thememofield As Odbc.OdbcParameter = sqlcmd.CreateParameter
    thememofield.OdbcType = Odbc.OdbcType.Text
    thememofield.ParameterName = "@thememofield"
    thememofield.Value = RADEDITpagetext.Html
    sqlcmd.Parameters.Add(thememofield)
    sqlcmd.Parameters.Add("@pageid", viewstate("pageid"))
    sqlcmd.ExecuteNonQuery()
    sqlcmd.Dispose()
    dbconn.Dispose()


    Based on the code that works it seems that the ODBC driver is misidentifying the data that is about to be inserted into the memo field. By explicitly telling it whats what everything works. Maybe I should be less lazy with my code!

    I should point out that not using parameters does not fix the problem either. Using a paramater as specified in the working code seems to be the only way around it this.

    This doesn't work:
    sqlcmd.CommandText = "update tablex set thememofield='" & replacequotesfunction(RADEDITpagetext.Html) & "' where pageid=?"


    I have not come across this problem in MySQL (the only other database I use). This fix came about from an article on an identical problem in classic ASP at Experts Exchange.
    http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21886137.html

    Reply

  • Telerik Admin admin's avatar

    Posted on Oct 4, 2006 (permalink)

    Hi Bryan,

    Thank you for sharing this information. It is strange indeed, as the problem does not exist with the SqlConnection object, nor have I met it with the OleDbConnection object.

    It is really a good-to-know problem with the ODBC driver.

    Cheers,
    Erjan Gavalji
    the telerik development team

    Reply

  • Bali avatar

    Posted on Mar 14, 2008 (permalink)

    The solution works for me!!!!  Saved a lot of time.. Thanx a lot..

    Reply

  • Sven avatar

    Posted on May 29, 2009 (permalink)

    Hi Forum

    I have the same error updating my MS Access 2000 mdb with a ASP.NET Formview:

    MyFormView.Update(True)

    but I'm not able to adapt your solution into my code, because my objects are defined in ASP.NET as a FormView with following SqlDataSource:

          <asp:SqlDataSource ID="dsMessageTemplates" runat="server" ConnectionString="<%$ ConnectionStrings:DSNBlaBla %>"
             ProviderName="<%$ ConnectionStrings:DSNBlaBla.ProviderName %>"
             UpdateCommand="UPDATE [Qry_Message_Templates] SET [Language_ID]=?, [MessageDisplaySite_ID] = ?, [MessageTemplType_ID] = ?, [MessageTemplate_Name] = ?, [MessageTemplate_Body] = ?, [MessageTemplate_Header] = ?&#13;&#10;WHERE [MessageTemplate_ID] = ?" >
                <UpdateParameters>
                    <asp:Parameter Name="Language_ID" Type="Int32" />
                    <asp:Parameter Name="MessageDisplaySite_ID" Type="Int32" />
                    <asp:Parameter Name="MessageTemplType_ID" Type="Int32" />
                    <asp:Parameter Name="MessageTemplate_Name" Type="String" />
                    <asp:Parameter Name="MessageTemplate_Body" Type="String" />
                    <asp:Parameter Name="MessageTemplate_Header" Type="String" />
                    <asp:Parameter Name="MessageTemplate_ID" Type="Int32" />
                </UpdateParameters>
          </asp:SqlDataSource>

    I have currently no idea how to adapt your code in the ASP-Code above. But your code works if I call it in a button-click event.

    Any ideas?

    BTW: I have to mention that if I use a AccessDataSource instead of a SqlDataSource it works without any code changes.

    cheerioh & thx
    Sven

    Reply

  • Telerik Admin admin's avatar

    Posted on Jun 1, 2009 (permalink)

    Hi Sven,

    This is a very old forum thread that you are reviving, and I am afraid that since the actual reason for the problem was never fully determined, the reasons in your case might turn out to be different.

    As originally noted by the person who started the thread, "I say sometimes as I have some pages using the code below which work fine and others that failed every single time."

    The second approach taken - which works - creates an OdbcParameter object.
    The main difference with this approach is that the .NET framework takes care of things such as, for example, encoding single quotes.

    This difference might well be the reason for the editor content to go fine on one page, and fail on another.

    Can you confirm that the error message which you receive is indeed "ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
    Exception Details: System.Data.Odbc.OdbcException: ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
    "


    Also, if it is the same error, is it possible to try using a AccessDataSource - since you are updating an Access database anyway? Also - do you get the error each time, even with the simplest content or only on occasions? Can you try to determine what content (symbol) is causing the problem?

    If you open a support ticket and send us a fully working project + steps to reproduce the problem, we will look deeper into it and get back to you with a solution + explanation what is happening.

    Best wishes,
    Tervel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

Back to Top

Skip Navigation LinksHome / Community / Forums / ASP.NET > Editor > Invalid Precision Value inserting data into Microsoft Access Memo field

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.