Print Page | Close Window

Passwords for datasource in GP

Printed From: Microsoft Dynamics Forums
Category: Microsoft Dynamics GP (Great Plains)
Forum Name: GP - Installation and Administration
Forum Discription: Installation, Upgrade, Service Pack, Security, Database, Administration, SQL Server, Login Issues, System Errors, Performance, EDI, Business Portal, and related topics
URL: http://www.MicrosoftDynamicsForums.com/forums/forum_posts.asp?TID=1202
Printed Date: June 01 2020 at 9:22am


Topic: Passwords for datasource in GP
Posted By: I hate GP
Subject: Passwords for datasource in GP
Date Posted: March 15 2007 at 1:41pm
I've been coding cheap code lately, and I really have to stop..
I want to know how can I create a datasource connection to the GreatPlains DB without the whole mess with the password?
 
Let me explain.
 
Usually, when one wants to create a data connection with ADODB, he/she would declare an ADODB.Connection object to create the connection, as well as an ADODB.Recordset object to hold the results of an SQL query. An example would be something like the following:
 
Dim cn As Object
Dim rs As Object
 
Set cn = new ADODB.Connection
Set rs = new ADODB.RecordSet
 
cn.ConnectionString = "Provider=MSDASQL;Data Source='MYGPDS';User ID='SA';Password='PASSWORD';Initial Client='TWO';"
rs.Open "Select * FROM RM00101 Where CUSTNMBR='Whatever'", cn, 0, 3
 
...
 
Okay, my question is, if I don't know the password to the datasource, how do I retrieve it programmatically, Or, How do I log in without having to enter a username and password? I ask because I have to install my mods (packages) on different computers for different companies, and to hardcode the password is not only cheap, but also leads to problems when installing the package on a computer where the datasource connection password is not "PASSWORD".
 
I've tried omitting the User ID and Password parameter with no success.
Also, I tried getting the password from the "WelcometoMicrosoftDynamics" window (modified), it works, but sometimes the variables holding the password values empty themselves out of the blue. Anybody know any alternatives?
 
 


-------------
Unoptimized code is useless code -- Type. Crash. Burn.



Replies:
Posted By: I hate GP
Date Posted: March 15 2007 at 2:12pm
Noticed some typos or whatever.. the connectionstring should be:
 
cn.ConnectionString = "Provider=MSDASQL;Data Source='MYGPDS';User ID='SA';Password='PASSWORD';Initial Catalog='TWO';"
 
and below it should be:
cn.Open
 
Just addressing them because it's correct in the actual code.. (gotta stop skipping coffee breaks..)
 
Anyway, anybody have a solution or know if it's even possible? Please help.


-------------
Unoptimized code is useless code -- Type. Crash. Burn.


Posted By: RobFleming
Date Posted: March 16 2007 at 7:09pm
Use the .dll provided by microsoft called retreiveglobals.dll. It'll pull login info from the GP session; you drop that login info into your connection string.  The only problem I've seen with it is that sometimes the object won't intstatiate and that causes problems; and the password for sa will not be returned.
 
It's a great way to provide a login w/out having uname/password combinations for your VBA mods.



Print Page | Close Window