Search the GP Tables
Search by TABLE NAME
Search by FIELD NAME
These are our SOP scripts. All of our scripts for Dynamics GP can be found here

Table Edits Forum Articles
Table Edits 0 Table Edits 0 Table Edits 0
Sign Up Now!Log In
joealt 8/9/2012 9:56:18 AM

Dexterity.GPConnection SQL Connection from GP Credentials

am attempting to make a connection to a Dynamics GP SQL Server Database using the currently logged in credentials from GP. (for context

Using the code provided from the documentation of GPConnNet.dll I should be able to get a connection but have been unable to do so for non-sa users, sa and dynsa work fine. I am receiving a login failed sql server error. I've tried both overloads of the Connect method, using the SqlConnection and an OdbcConnection.

SqlConnectionStringBuilder cb = new SqlConnectionStringBuilder(connectionString);
SqlConnection sqlConn = new SqlConnection();
if (sqlConn.State != ConnectionState.Open)
var gpconn = new GPConnection();
.Init(<Key1>, <Key2>);
.ConnectionString = string.Format("database={0}", cb.InitialCatalog);
.LoginCompatibilityMode = false;
.Connect(sqlConn, cb.DataSource, cb.UserID, cb.Password);
if (gpconn.ReturnCode != 1)
throw new AuthenticationException("Could not authenticate with the GP credentials.");
catch (System.Runtime.InteropServices.SEHException)
throw new AuthenticationException("Could not authenticate with the GP credentials.");

The information in the connection string is coming from the Microsoft Dexterity toolkit.

public class GPUser
public readonly static string DataBase = Dynamics.Globals.IntercompanyId.Value;
public readonly static string UserID = Dynamics.Globals.UserName.Value;
public readonly static string Password = Dynamics.Globals.SqlPassword.Value;
public readonly static string DataSource = Dynamics.Globals.SqlDataSourceName.Value;
public readonly static string ApplicationName = string.Format("{0}{1}", App.ProductName, "(gp)");
public static string Server
//Returns the Server from the ODBC DSN
public static SqlConnectionStringBuilder ConnectionString
return new SqlConnectionStringBuilder
DataSource = Server,
UserID = UserID,
Password = Password,
ApplicationName = ApplicationName,
InitialCatalog = DataBase


Is there something security related that is required on the user? Is there something in the GPConnection code that I'm missing?


Version: GP 2010
Section: .NET Development, Dexterity, Dynamics GP, Visual Studio Tools for Dynamics GP

Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables