Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interop error -2147467259

Status
Not open for further replies.

badmotorvision

Programmer
Oct 15, 2009
22
0
0
US
Ok, Im new to the ACCPAC SDK. Im using VS2005 / VB.net
and executing the sample code included in the sdk.
and receiving an com exception -2147467259 on the following
code.
session = New ACCPAC.Advantage.Session
session.Init("", "XX", "XX1000", "52A")
Try
session.Open("ADMIN", "", "TESINC", DateTime.Today, 0)
Catch ex As Exception
Dim m As String
m = ""
Catch ex As ACCPAC.Advantage.SessionException
Dim m As String
m = ""
End Try
Im going to forward this error to my reseller but I thought I might tap this group first. The exception is thrown on the session.open statement.
I am ref. ACCPAD.Advantage.dll and ACCPAC.Advantage.Types.dll in my project references.
 
For starters the web interface is a waste of time, and secondly you are far better off using VB6.
Try using "ADMIN" for the password as well.

Which version of Accpac?
 
ACCPAC Ver 5.5a and we dont own a copy of VB6.
We only switch from java a few years ago to the .net platform. When using "ADMIN" for a password I get an invalid userid/pass error. Password is not required to login to accpac
 
At least that is progress, get the proper ADMIN password and try that. And yes ADMIN has to have a password, if it is not ADMIN then it is something else. Note that the password is always upper case. VB6 is still available, check on eBay.
 
Well I'm not sure if you resolved your issue yet, but here are some things that could help.

First of all you want to use the 'ACCPAC XAPI 1.1 Type Library' COM reference from your project. This will give you access to the object you need to get the job done. I know all the examples that Sage gives you use the Accpac.Advantage / .Types.dll but you should really use the XAPI.

Once you have your XAPI reference you need to create the function to get XAPI errors for you, something like this but in this case i have a global Session object, you might need to pass yours in;

This is C# but you should easily be able to convert to VB.NET
Code:
/// <summary>
/// Gets any XAPI errors and clears them from the XAPI
/// </summary>
/// <returns></returns>
private string GetXAPIError()
{
    long lCount;
    int iIndex;
    string ret = string.Empty;

    if (pSession.Errors != null)
    {
        lCount = pSession.Errors.Count;

        if (lCount != 0)
        {
            for (iIndex = 0; iIndex < lCount; iIndex++)
            {
                ret += pSession.Errors.Item(iIndex).Description;
            }
            pSession.Errors.Clear();
        }
    }

    return ret;
}

Once you can actually get the XAPI errors you should be able to get a better idea of why your log in is failing.
Here is some sample code i used to log into accpac;

Once again C#, but just convert to VB.NET
Code:
/// <summary>
/// Signs into Accpac using the credentials specified
/// </summary>
/// <param name="user">The user name for accpac</param>
/// <param name="password">The password for accpac</param>
/// <param name="database">The database that should be used</param>
/// <returns></returns>
public bool SignOn(string user, string password, string database)
{
    try
    {
        pSession.Open(user, password, database, DateTime.Today, 0);
        return true;
    }
    catch
    {
        string xapiErr = GetXAPIError();

        if (!string.IsNullOrEmpty(xapiErr))
            throw new Exception(xapiErr);
        else
            throw;
    }

}

/// <summary>
/// Signs out of accpac
/// </summary>
public void SignOut()
{
    pSession.Close();
}

After that everything should be a breeze, here is another sample function i used to open views for me.

C# again, but bla bla bla
Code:
/// <summary>
/// Opens an accpac view
/// </summary>
/// <param name="ViewID">The ID of the view to open</param>
/// <returns></returns>
private ACCPACXAPILib.xapiView OpenView(string ViewID)
{
    return (ACCPACXAPILib.xapiView)pSession.OpenViewEx(ViewID, ProgramID, 0);
}

Hope this helps [afro]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top