Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

sql Connection string for non sa user in microsoft dynamic gp

(0) ShareShare
ReportReport
Posted on by 430

 

I am trying to connect non sa user using below method...

        public void ConnectionForDataBase()

        {

            SqlConnection myConnection = new SqlConnection();

            SqlCommand myCommand = new SqlCommand();

            SqlDataAdapter dr = new SqlDataAdapter();

            DataSet ds = new DataSet();

            Microsoft.Dexterity.GPConnection GPConnobj;

            int result = 0;

             Microsoft.Dexterity.GPConnection.Startup();

  GPConnobj = new Microsoft.Dexterity.GPConnection();

 

            // Init function 

            result = GPConnobj.Init("<key1>", "\"key2l>");

            myConnection.ConnectionString = ("DataBase=" + Dynamics.Globals.IntercompanyId.Value);

 

            //Connect method 

            GPConnobj.Connect(myConnection, Dynamics.Globals.SqlDataSourceName.Value, Dynamics.Globals.UserId.Value, Dynamics.Globals.SqlPassword.Value);

            GPConnobj.LoginCompatibilityMode = true;

 

            string connection = myConnection.ConnectionString;

            // MessageBox.Show("Connection : " + myConnection.ConnectionString);

            string password = Dynamics.Globals.SqlPassword.Value;           

            connection = myConnection.ConnectionString + "Password=" + password;

         if ((GPConnobj.ReturnCode & (int)GPConnection.ReturnCodeFlags.SuccessfulLogin) == (int)GPConnection.ReturnCodeFlags.SuccessfulLogin)

            {                   MessageBox.Show("succesful login");             }

            else

            {

                MessageBox.Show("Unsuccesful login. Please contact your system administrator.");

            }

 

 

Final connection string is : string connection = "data source=Rohri;initial catalog=TWO;persist security info=False;User ID=client;Password=xxx";

I am getting login Failure  for "client'.

if i connect with sa .then it is woking fine .if connect with non sa user i am getting errros.

If i use datasource as Dynamic gp 2010. i am sql instance not activated. like that i am getting errors. 

Please give me the suggeiton how can i work with non sa user.

 

*This post is locked for comments

  • k@vi Profile Picture
    k@vi 430 on at
    Re: sql Connection string for non sa user in microsoft dynamic gp

    Hi Tim w ,

    I am using two different connection strings. There are DYNAMIC  and TWO.

    This is connetion string  for DYNAMIC Database :

    Data Source=Rohri;Initial Catalog=DYNAMICS;Persist Security Info=False;User ID=client1;

    This  is for TWO Database :

    Data Source=Rohri;Initial Catalog=TWO;Persist Security Info=False;User ID=client1;

    DYNAMIC is working but not for TWO database.

    Can you please tell me where i am doing mistake.

  • Tim W Profile Picture
    Tim W 2,925 on at
    Re: sql Connection string for non sa user in microsoft dynamic gp

    MSFT would be the ticker symbol for MicroSoFT but in this context means someone in Fargo at Tools Support.

    Someone there issued you the key (which has been cleared out of your post as it is a real reg key)  result = GPConnobj.Init("<key1>", "\"key2l>");

    I would think you need to validate that <key2> is your password to access the GPConn dll, and is correct after the compiler interprets your string.  Somewhere you should have an e-mail with that password.  Set a break point and see that it matches character to character from your code in debug mode before you call the dll.  Looking at your code, I think that is (was when I could see it anyway) your issue.

     

     

  • k@vi Profile Picture
    k@vi 430 on at
    Re: sql Connection string for non sa user in microsoft dynamic gp

    What is MSFT ?

  • Tim W Profile Picture
    Tim W 2,925 on at
    Re: sql Connection string for non sa user in microsoft dynamic gp

    It looks right to me, in fact I was looking at a current project where I was having a connection issue and realized I was passing interco id rather than the server name in the Connect so looking at your code helped me catch my bug.

    What I think the issue might be is you not qualifying the " (double quote) in your Init password.  I had to triple quote mine """ to get a " to read in the password.  I'm not sure what your password is but the \ would hide the " and I think that might be the problem.  Another tip if you have the sample programs from MSFT is to use their connection string to test your code ahead of adding your own Init password.

    Tim

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans