SQL queries: parameters' types specific or universal?

5 posts, 0 answers
  1. tmlipinski
    tmlipinski avatar
    131 posts
    Member since:
    Dec 2006

    Posted 15 May 2009 Link to this post

    Hi,

    Let's assume I have such instructions (working under MS SQL Server):
    IQuery query = scope.GetSqlQuery("select * from MyTable where Name = ?"null"nvarchar name");  
    IQueryResult res = query.Execute(new object[] { "aqq" }); 
    Is "nvarchar" server-specific or universal? I mean - will it work for Oracle too or I must change it as "nvarchar2 name"? If it is server-specific - how can I determine the type of currently used server?

    Regards
    Tomasz
  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 15 May 2009 Link to this post

    Hi tmlipinski,
    Sql is always backend specific. Why do you use sql instead of oql or linq?

    Best wishes,
    Jan Blessenohl
    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.
  3. DevCraft banner
  4. tmlipinski
    tmlipinski avatar
    131 posts
    Member since:
    Dec 2006

    Posted 15 May 2009 Link to this post

    Hi,
    Thanks for the quick reply.
    In general I use OQL, of course. But sometimes I need to use SQL - for example to read data from a view, not from tables directly; or to execute a stored procedure from another database; or to ask a complex, analytical query. 
    So, my last question is still valid: how can I determine the type of the currently connected server?

    Regards
    Tomasz
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 15 May 2009 Link to this post

    Hi tmlipinski,
    The only way at the moment is to use Database.ConnectionURL. This string contains a "backend=" part that gives you the specified backend string like mssql or oracle.

    Sincerely yours,
    Jan Blessenohl
    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.
  6. tmlipinski
    tmlipinski avatar
    131 posts
    Member since:
    Dec 2006

    Posted 15 May 2009 Link to this post

    HI,
    OK, that's enough. Thanks.

    Regards
    Tomasz
Back to Top
DevCraft banner