I am having problems executing stored procedures on SQL Server 2005 Express.. This approach has always worked for me in the past..
On the server i have done the following:
1. Created user 'TimesUser' on the server.
2. Created the role 'DB_Executor' on the database using the following code.
The user account 'TimesUser' is therefore mapped it to the following roles:
1. DB_DataReader
2. DB_DataWriter
3. DB_Executor
From my access application, I call the generic following code to execute the proc. The code refers to globall for credentials, all are correct.
Any ideas why it doesn't work?
On the server i have done the following:
1. Created user 'TimesUser' on the server.
2. Created the role 'DB_Executor' on the database using the following code.
Code:
CREATE ROLE db_executor
GRANT EXECUTE TO db_executor
EXEC sp_addrolemember 'db_executor', 'username'
The user account 'TimesUser' is therefore mapped it to the following roles:
1. DB_DataReader
2. DB_DataWriter
3. DB_Executor
From my access application, I call the generic following code to execute the proc. The code refers to globall for credentials, all are correct.
Code:
Public Sub ExecuteProc(ProcName As String)
On Error GoTo PROC_ERR
Dim cmd As New ADODB.Command
Dim cnn As New ADODB.Connection
Dim stConnect As String
On Error Resume Next
DoCmd.Hourglass True
stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & SQLServer_Name & ";DATABASE=" & SQLServer_DatabaseName & ";UID=" & SQLServer_usr & ";PWD=" & SQLServer_pwd
Debug.Print stConnect
cnn.Open stConnect
With cmd
.ActiveConnection = cnn
.CommandType = adCmdStoredProc
.CommandText = ProcName
.Execute
End With
PROC_EXIT:
On Error Resume Next
DoCmd.Hourglass False
cnn.Close
Set cnn = Nothing
Set cmd = Nothing
Exit Sub
PROC_ERR:
MsgBox Err.Number & vbCrLf & Err.Description
Resume PROC_EXIT
End Sub
Any ideas why it doesn't work?