none
DataSet using ODBC giving error HY104 Invalid precision value RRS feed

  • Question

  • I'm connecting to an old Unix database via an ODBC driver provided by the database vendor (the Unify Corporation). It's gving me a few problems, most of which I'm pursuing with the vendor, but I'm hoping I might be able to get some help here for the following problem:-

     

    When I try to Add a paramerised query to a DataTable in the DataSet Designer (using the '?' for positional parameters), I get the following error :-

    “ERROR [HY104] [Unify][UnifyClient ODBC Driver]Invalid precision value.”

     

    The error shows on the 'Wizard Results' page of the 'Table Adapter Query Configuration Wizard',  after I click 'Next' on the 'Choose Methods to Generate' page.

     

    If I click 'Finish' here it does generate the command, but gives the HY104 error at runtime.

     

    This only happens when the parameter refers to a STRING field.

     

    I can create paramterised commands in C#, add parameters and run the query properly.

     

    I've stripped down the generated code from the designer.cs, and the problem seems to be that the generated code for the parameter creation (see below) defaults the 'size' to 1024. If I reduce this manually (to a value below 511) the command works.

     

    new global:Tongue Tiedystem.Data.Odbc.OdbcParameter("supplier", global:Tongue Tiedystem.Data.Odbc.OdbcType.VarChar, 1024, global:Tongue Tiedystem.Data.ParameterDirection.Input, ((byte)(0)), ((byte)(0)), "supplier", global:Tongue Tiedystem.Data.DataRowVersion.Current, false, null))

     

    I think 512 is the maximum size of a STRING field in this database.

    Changing OdbcType.VarChar to OdbcType.Char didn't help.

    The DataSet designer reports that the "supplier" column type is System.String, with MaxLength 12.

     

    Is there any way I can get at the default value in the designer, or is there anything the vendor can do in their ODBC driver ?

     

    Interstingly, If I use Query Builder during the Add Query dialog, I can set a filter "= ?" on the supplier column and Execute the command, and it prompts me properly for the parameter value and displays the correct result. The query it leaves behind still gives the HY104 error later on in the Wizard Results page

    Monday, December 10, 2007 10:42 AM

Answers

  • I had to shelve this project for a while, and when I came back to it fresh, I found a solution to this (if anybody's still interested).

     

    In the dataset designer, right-click on the offending query allows you to edit the properties. One of these properties is the Parameters collection, and this allows you to edit the "Size" of the parameter. It's a pain having to remember to do it, but it works.

     

    Thursday, October 9, 2008 7:17 PM

All replies

  • I had to shelve this project for a while, and when I came back to it fresh, I found a solution to this (if anybody's still interested).

     

    In the dataset designer, right-click on the offending query allows you to edit the properties. One of these properties is the Parameters collection, and this allows you to edit the "Size" of the parameter. It's a pain having to remember to do it, but it works.

     

    Thursday, October 9, 2008 7:17 PM
  • Thanks helped me a lot ......not know what to do...I don't speak english only Spanish..but I try speak english.....me fuiste de gran ayuda
    Sunday, March 15, 2009 12:45 AM
  • I had the same problem, and thanks to pagoni i solved!! 

    I got an Access OLE connection, and when i create a scalar query with parameters, VS returns an error (HY104).

    I skipped this error, and in Properties i changed the dbtype to string and the Size to 255 (same of the field size in access db).

    Now it magically works. 

    Is it an impression of mine, or does VS hate Access DB? 

    Thanks for help

    Thursday, April 1, 2010 8:06 AM
  • A big THANK YOU to Pagoni !!!
    Thanks for taking the extra time to find the ultimate solution. You saved me alot of time.


    Kevin A. Baroni - K.A.B. Consulting - http://www.kabconsulting.com - (916) 253-9770
    Sunday, June 19, 2011 1:41 AM
  • Yep, that was exactly the issue.

    Much appreciated and well done. I see you did this over 6 years ago but great to see it's still valid even in Visual Studio 2013.

    Cheers

    Saturday, October 25, 2014 12:13 AM