MS Sql 2005 Text column

6 posts, 1 answers
  1. Brian Goldman
    Brian Goldman avatar
    34 posts
    Member since:
    Mar 2005

    Posted 10 Dec 2008 Link to this post

    This may have been mentioned before, I couldn't find it. When using a text column I get an error
    SqlCommand.Prepare method requires all variable length parameters to have an explicitly set non-zero Size.

    Any workaround?

    Thanks,
    Brian


  2. Answer
    Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 12 Dec 2008 Link to this post

    Hello Brian Goldman,
    We need the length definiton of 0 in the mapping file for Text columns. You can do that in the mapping dialog or directly in the mapping file like this:

              <class name="Person"
                <field name="name"
                  <extension key="db-column"
                    <extension key="db-sql-type" value="TEXT" /> 
                    <extension key="db-length" value="0" /> 
                  </extension> 
                </field> 
              </class> 
     

    Best wishes,
    Jan Blessenohl
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Jouie
    Jouie avatar
    9 posts
    Member since:
    Nov 2007

    Posted 06 Apr 2009 Link to this post

    Hi Jan,

    I used your solution above but I got this error:

    "Update failed: Telerik.OpenAccess.RT.sql.SQLException: The data types text and varchar are incompatible in the equal to operator.\r\nStatement(s) could not be prepared.\r\n   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate()\r\n   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate()\r\n   at OpenAccessRuntime.Relational.RelationalStorageManager.generateUpdates(OID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, Boolean haveNewObjects, CharBuf s)\nRow: GenericOID@7 Template template_id=6\nUPDATE [template] SET [content_html]=? WHERE [template_id] = ? AND [content_html]=?\n(set event logging to all to see parameter values) Telerik.OpenAccess.RT.sql.SQLException: The data types text and varchar are incompatible in the equal to operator.\r\nStatement(s) could not be prepared.\r\n   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate()\r\n   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate()\r\n   at OpenAccessRuntime.Relational.RelationalStorageManager.generateUpdates(OID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, Boolean haveNewObjects, CharBuf s)"

    Below is the mapping sample:

     

     

    <class name="Template">     
         <extension key="db-do-not-create-table" value="true" />     
         <extension key="db-table-name" value="template" />     
         <field name="templateId">     
            <extension key="db-column">     
               <extension key="db-type" value="INTEGER" />     
               <extension key="db-column-name" value="template_id" />     
            </extension>     
         </field>     
         <field name="contentHtml">     
            <extension key="db-column">     
               <extension key="db-sql-type" value="TEXT" />     
               <extension key="db-length" value="0" />     
            </extension>     
         </field>     
         <field name="contentText">     
            <extension key="db-column">     
               <extension key="db-sql-type" value="TEXT" />     
               <extension key="db-length" value="0" />     
            </extension>     
         </field>    
    </class> 

    Is there a way to set just the primary key as the only parameter in the where clause of generated statement? Or any workaround?

    Thanks,

    Jouie

  5. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 07 Apr 2009 Link to this post

    Hi Jouie,

    please add an additional

          <extension key="db-type" value="LONGVARCHAR" />

    to the respective column  mapping (also doable via the forward mapping dialog). This extension avoids that the column is handled as an updatable column. Please note, that also in your case the db-optimistic-locking with 'changed' seems not to work well as no other columns are then checked; maybe you should switch to a version field for concurrency control.

    Kind regards,
    Thomas
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Thomas
    Thomas avatar
    9 posts
    Member since:
    Sep 2008

    Posted 22 Apr 2009 Link to this post

    Hello.

    I have exactly the same problem. But all extensions won't help.
    This is was an example column looks:
    1 <field name="vgsEmaUeberwachungsbereich">  
    2   <extension key="db-column">  
    3     <extension key="db-type" value="LONGVARCHAR" /> 
    4     <extension key="db-column-name" value="vgs_ema_ueberwachungsbereich" /> 
    5     <extension key="db-sql-type" value="TEXT" /> 
    6     <extension key="db-length" value="0" /> 
    7   </extension> 
    8 </field> 

    My current workaround is that I store null into the properties which seems to work. How do I solve this so that I can store empty strings ( like string.Empty ) into the db?

    Regards,
    Thomas
  7. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 24 Apr 2009 Link to this post

    Hello Thomas,

    I've just identified the problem (MSSQL does not allow 0 as a valid size in the ADO parameter) and the next build will contain the patch.
    Workaround: Specify a large (10000000) number as the db-length. This will not alter your table.

    Sincerely yours,
    Thomas
    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.
Back to Top
DevCraft banner