SQL Server Application Roles (sp_setapprole)

Posts   
 
    
gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 04-Feb-2010 15:46:43   

Hi,

I've seen some old threads about this. In the mean time, is there anyone who succesfully implemented LLBLGen based on a underlying connection that's using an AppRole?

I would prefer self-servicing as that's what we always use, otherwise comments on using Adapter would be welcome too.

Thanks, Gabriƫl

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 04-Feb-2010 21:40:57   

I'm assuming that you've seen this thread http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12594&HighLight=1 which details the changes you need to make to the code to get application roles to work.

Other than that, sorry, but I have nothing else to add as I've never used them. Some of the other support team may be able to add more information.

Matt

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 05-Feb-2010 09:02:56   

Nope, missed that one!

Thanks!

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 05-Feb-2010 12:22:07   

Hi,

I implemented everything as described, but now I get the following error upon creating a new connection now and then:


A severe error occurred on the current command.  The results, if any, should be discarded.

From these lines:


            SqlCommand _SqlCommand = new SqlCommand();
            _SqlCommand.Connection = _SqlConnection;
            _SqlCommand.CommandType = CommandType.StoredProcedure;
            _SqlCommand.CommandText = "sp_setapprole";
            _SqlCommand.Parameters.Add(new SqlParameter("@rolename", _RoleName));
            _SqlCommand.Parameters.Add(new SqlParameter("@password", _Password));
            _SqlCommand.Parameters.Add(new SqlParameter("@fCreateCookie", true));

            SqlParameter _CookieSqlParameter = new SqlParameter("@cookie", SqlDbType.VarBinary, 8000);
            _CookieSqlParameter.Direction = ParameterDirection.Output;
            _SqlCommand.Parameters.Add(_CookieSqlParameter);

            try
            {
                _SqlCommand.ExecuteNonQuery();  <<-----------
                m_CookieByteArray = _CookieSqlParameter.Value as byte[];
            }
            finally
            {
                _SqlCommand.Dispose();
            }

It's a sort of at random, any suggestions?

It's a SQL 2008 DB, 64-bit. Using LLBLGen 2.6, Adapter.

http://support.microsoft.com/kb/938102/en-us

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 08-Feb-2010 09:04:53   

Maybe the connection already has an open command/role set.

Do you have a stack trace? Or maybe a trace from SQL Profiler?

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 18-Feb-2010 23:24:38   

Problem was not calling .Dispose() on the Adapter (sorry, used to self-service)