Hi Guys,
I am working on integration of my .net application with microsoft GP using GP connect dll for database connection. But it is not connecting to database and returning 2 as end result. After doing analysis of code i found that this happening because my init method in GP connect dll is returning 7.as given below. Init method is return 7 in response variable. Please suggest when it return 7 and when it returns 0.
static void Main(string[] args)
{
OdbcConnection cn = new OdbcConnection();
OdbcCommand cmd = new OdbcCommand();
OdbcDataReader rst;
Int32 resp;
GPConnection GPConnObj;
// Call Startup
resp = GPConnection.Startup();
// Create the connection object
GPConnObj = new GPConnection();
// Initialize
int response= GPConnObj.Init("<Key1>", "<Key2>");
// Make the connection
cn.ConnectionString = "DATABASE=TWO";
GPConnObj.Connect(cn, "LocalServer", "LESSONUSER1",
"access");
// Check the return code
if ((GPConnObj.ReturnCode &
(int)GPConnection.ReturnCodeFlags.SuccessfulLogin) == (int)GPConnection.ReturnCodeFlags.SuccessfulLogin)
{
// Specify the command retrieve all customers
cmd.Connection = cn;
cmd.CommandText = "Select * From RM00101";
// Execute the command
rst = cmd.ExecuteReader();
rst.Read();
// Display the name of the first customer
Console.WriteLine(rst.GetValue(1).ToString());
Console.ReadLine();
// Close the connection
cn.Close();
}
else
{
Console.WriteLine("Login failed");
Console.ReadLine();
}
// Dispose of the connection object
GPConnObj = null;
// Call Shutdown
resp = GPConnection.Shutdown();
}
}
Thanks
Amit Kumar
*This post is locked for comments