Quantcast
Channel: Microsoft Dynamics GP
Viewing all articles
Browse latest Browse all 59474

Forum Post: RE: Get SQL connection string or run sp or query using VS Tools for GP

$
0
0

Here is the code I use to establish the connection

You will need to register with Microsoft to get the license keys. I believe you can ask your partner to get you these keys.

   GPConnObj.Init("MyCompanyName", "MyLicenseKeys");

private SqlConnection GetConnection()

       {

           SqlConnection DataConnection = new SqlConnection();

           /* Call Startup */

           resp = GPConnection.Startup();

           /* Create the connection object */

           GPConnObj = new GPConnection();

           /* Initialize the connection object */

           GPConnObj.Init("MyCompanyName", "MyLicenseKeys");

           /* Make the connection */

           DataConnection.ConnectionString = "Database=" + Dynamics.Globals.IntercompanyId.Value;

           GPConnObj.Connect(DataConnection, Dynamics.Globals.SqlDataSourceName.Value, Dynamics.Globals.UserId.Value, Dynamics.Globals.SqlPassword.Value);

           /* Check the return code */

           if ((GPConnObj.ReturnCode & (int)GPConnection.ReturnCodeFlags.SuccessfulLogin) !=

               (int)GPConnection.ReturnCodeFlags.SuccessfulLogin)

           {

               MessageBox.Show("Login failed");

           }

           return DataConnection;

       }


Viewing all articles
Browse latest Browse all 59474

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>