web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

SQL Server Message 916

(0) ShareShare
ReportReport
Posted on by 580

SQL Server Message 916 - The server principal "domain\username" is not able to access the database "NAMEOFDB" under the current security context. 

 

Get the above message when I try to execute a custom stored procedure I created in the System database

 

Call SqlFetch1(cursorNbr, "System.dbo.sp_UserAccess_1" + SParm(myuserid) + SParm("ACCOUNTANTS") + SParm(mycompanyid), isAuthorised, LenB(isAuthorised))

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Ajit Kannan Profile Picture
    1,246 on at

    Hi,

    Give the grand permission to this procedure

    For SL 2011:

    GO

    GRANT EXECUTE ON xxxx TO [E8F575915A2E4897A517779C0DD7CE] AS [dbo]

    GO

    GRANT CONTROL ON xxxx TO [MSDSL] AS [dbo]

    GO

    For SL 7:

    GO

    GRANT EXECUTE ON xxxx TO [E7F575915A2E4897A517779C0DD7CE] AS [dbo]

    GO

    GRANT CONTROL ON xxxx TO [MSDSL] AS [dbo]

    GO

    Thanks

    Ajit Kannan S R

  • Suggested answer
    Apps Mexico Profile Picture
    1,090 on at

    Hi,

    You have to change the way that you read the useraccess table.

    1. Add the useraccess dh.
    2. Declare an useraccess cursor with the SqlSystemdb flag

    Example:

    DH Code:

    Public CSR_UserRec As Integer

    Public serr_UserRec As Integer

    Public Sub Init_UserRec(ByRef x_Level As Integer, ByRef x_Cursor As Boolean)
    Call VBA_SetAddr("bUserRec", bUserRec, nUserRec, Lenb(bUserRec))
    If x_Cursor = True Then
    Call SqlCursorEx(CSR_UserRec, x_Level + SqlSystemdb, "CSR_UserRec", "UserRec", "UserRec")
    End If
    End Sub

    Form1 Code:

    Private Sub Form1_Load()
    Call Init_UserRec(NOLEVEL, True)
    End Sub

    Method or Function Call:

    Call GetBufferValue("bpes.userid", sUserID)
    serr_UserRec = SqlFetch1(CSR_UserRec, "UserRec_Type_UserId" & SParm("U") & SParm(sUserID), bUserRec, LenB(bUserRec))

  • Jo Wykerd Profile Picture
    1,639 on at

    Hi there,

    I am getting the same error as above.  All i am trying to do is access field User1 in the table UserRec in the System database.  I am accessing it in a VBA customisation on the Journal Transaction screen (01.010.00)

    Dim SProj As String * 30
    Dim Suserid As String * 30

    Call GetBufferValue("bpes.userid", Suserid)

    SqlStr = "select * from vs_userrec where userid = '" & Suserid & "'"
    serr1 = SqlFetch1(c1, SqlStr, bUserRec, LenB(bUserRec))

    If serr1 = 0 And bUserRec.User1 = 1 Then GoTo no_override

    SProj = Trim(GetObjectValue("cprojectid"))

    If RTrim(SProj) <> "" Then

    Call setprop("csub", PROP_ENABLED, False)

    Else
    Call setprop("csub", PROP_ENABLED, True)

    End If

    no_override:

    Any suggestions to get round it? 

    Thank!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans