Respondida linq to sql permissions

  • Tuesday, February 05, 2013 2:59 AM
     
     

    In a C# 2008 desktop application that uses linq to sql to connect to a sql server 2008 r2 database, I am getting an error message. The error message did not occur when I was executing the application on my own workstation and I am  pointing to a test database where I have sa priviledges. This database also has 3 new triggers on one particular database. This error occurs when I am pointing to a different test database.

    I am getting the following error:
    2013-02-04 16:13:58.5695|ERROR|sampleclient.Sample|Error Processing --> Specified cast is not valid.
    2013-02-04 16:13:58.5695|ERROR|sampleclient.Sample|************* Stack Trace *******************
    2013-02-04 16:13:58.5851|ERROR|sampleclient.Sample|   at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
       at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
       at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
       at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)

    Can you tell me if my problem can be permissions on the database? If so can you tell me what type of permission I need to give to the triggers?

All Replies

  • Tuesday, February 05, 2013 8:31 AM
     
     

    This is not a permission issue, Debug your code with stepping in, debugger will stop on exact variable where it throws Specified cast is not valid exception, if it is SQL function's or stored procedure's fault, otherwise search errors in triggers.

    It happened with me lots of times, when LINQ throws exception but procedure was ok and finally I could find exception in Triggers.


    Please Mark as Reply and Vote as Helpful if I helped.

    Also please visit my blog http://msguy.net/

  • Tuesday, February 05, 2013 1:36 PM
     
     
    What kind of exception in the triggers do I need to look for?
  • Tuesday, February 05, 2013 2:30 PM
     
     Answered
    I don't know what trigger can throw, I'm just addressing to the problem that may happen. From your scenario it looks like your exception is thrown on LINQ layer. So did you managed to run the debug mode and step in the execution of your LINQ statement?

    Please Mark as Reply and Vote as Helpful if I helped.

    Also please visit my blog http://msguy.net/

    • Marked As Answer by wendy elizabeth Wednesday, February 06, 2013 2:13 AM
    •