Friday, March 30, 2012

Log in to SQL using VBA in Access.

Hello, hope you guys can help me out on this one. I have an MS Access App. that uses SQL as the backend through ODBC. I would like to force my Access App. to use a specific user account every time it queries the SQL Database.

Can someone give me a code example of a VBA string I can use to completely bypass whatever user is logged into the workstation, and have my app use a user account I specify within the VBA code.

Your help is much appreciated.
JovixTry this:
"Driver={SQLServer};Server=Your_Server_Name;Databas e=Your_Database_Name;Uid=Your_Username;Pwd=Your_Pa ssword;"

And check this website (might be helpful). http://www.sqlstrings.com/|||I'd be inclined to look at sp_setapprole (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_sa-sz_6tt1.asp) instead. This allows every user to retain their own identity (so you can later blame the innocent), while allowing your application to use a single signon to the database that isn't available to the users (to allow you to protect the guilty).

-PatP|||^^ Thanks guys...to get my app running asap, I'll use the Driver string. But I'll definetely look into sp_setapprole.

No comments:

Post a Comment