SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


VBA - Access to the remote server is denied because no login mapping exists


VBA - Access to the remote server is denied because no login mapping exists

Author
Message
khurmi.navpreet
khurmi.navpreet
SSC Journeyman
SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)

Group: General Forum Members
Points: 78 Visits: 23
Hello,

I had a VBA code which has been running fine for the last one year and then it suddenly stopped working.
Basically in this code I am just executing a Stored Procedure on a SQL Server Database.
Also I checked and the readonly user does exist.

connStr = "Driver={SQL Server};Server=SQL20;Database=ABC;user id=readonly;password="

Dim Cmd1 As ADODB.Command

'Setup the connection to the database
Dim connection As ADODB.connection
Set connection = New ADODB.connection
connection.ConnectionString = connStr
'connection.ConnectionTimeout = 500

connection.Open

'Open recordset
Set Cmd1 = New ADODB.Command
Cmd1.ActiveConnection = connection

Cmd1.CommandText = "SPCreate"

Cmd1.CommandType = adCmdStoredProc


Cmd1.Parameters("@pileNum").Value = pileNum
Cmd1.Parameters("@startDate").Value = CDate(startDt)
Cmd1.Parameters("@endDate").Value = CDate(endDate)


Dim myRecordset As ADODB.Recordset

Cmd1.CommandTimeout = 500
Set myRecordset = Cmd1.Execute() - THIS IS WHERE IT GIVES THIS ERROR (Access to the remote server is denied because no login-mapping exists)
HanShi
HanShi
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13108 Visits: 3749
Please make it clear if it involves a MS Access database (because you posted this in the MS Access forum) or a SQL Server database (like you mention in the post).

If it involves SQL:
- Check for any errors in the SQL Error log
- Check if the login you use still exists on the instance
- Check if the login has the correct permissions on the database
- Check if the login is connected to the user in the database: use {db_name};exec sp_change_users_login 'Report'


If it involves MS Access:
- Can you manually start MS Access, open the database and execute the command (using the user credentials you use in the code)

** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
khurmi.navpreet
khurmi.navpreet
SSC Journeyman
SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)

Group: General Forum Members
Points: 78 Visits: 23
- Check for any errors in the SQL Error log - NO ERROR
- Check if the login you use still exists on the instance - DOES EXIST
- Check if the login has the correct permissions on the database - YES
- Check if the login is connected to the user in the database: use {db_name};exec sp_change_users_login 'Report' - Executed this command but it gave me only 2 usernames with UserID's.
HanShi
HanShi
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13108 Visits: 3749
khurmi.navpreet (8/15/2013)- Check if the login is connected to the user in the database: use {db_name};exec sp_change_users_login 'Report' - Executed this command but it gave me only 2 usernames with UserID's.


The 2 usernames with the UserID's indicate that a connection between the user and the login is lost. The connection is lost due to a mismatch between the UserID's of the Login and the corresponding User. Most probably a database restore is executed or the login is deleted and re-created.
You can use the following command for each listed username to re-connect them again:
use {db_name};exec sp_change_users_login 'Auto_fix', '{username}'



** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search