Forum d'entraide Acomba
Pourquoi ne pas devenir membre du forum ?

Identifiez-vous ou Inscrivez-vous afin d'accéder à l'inrégralité du forum:
Accès à toutes les catégories du forum,
Entraide entre les 6 500 membres, et ce nombre s'accroît quotidiennement!

Notez que ce forum est indépendant de la société Acceo Solutions, éditrice du logiciel Acomba.

Rejoignez le forum, c’est rapide et facile

Forum d'entraide Acomba
Pourquoi ne pas devenir membre du forum ?

Identifiez-vous ou Inscrivez-vous afin d'accéder à l'inrégralité du forum:
Accès à toutes les catégories du forum,
Entraide entre les 6 500 membres, et ce nombre s'accroît quotidiennement!

Notez que ce forum est indépendant de la société Acceo Solutions, éditrice du logiciel Acomba.
Forum d'entraide Acomba
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Connexion
-17%
Le deal à ne pas rater :
SSD interne Crucial SSD P3 1To NVME à 49,99€
49.99 € 59.99 €
Voir le deal

Aller en bas
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Crash on FindKey

Mer 15 Déc 2010 - 11:14
Hello,

I got crash on iError = Acomba.FindKey(UserIndex, 1)

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in WindowsApplication1.exe

Additional information: Catastrophic failure

I add AcoX0127 to vb->reference->com and then copy the code from the sample.

Here is the code:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Interface declarations
Dim Acomba As New AcoX0127.AcombaX
Dim UserIndex As New AcoX0127.UserKey

'Variable declarations
Dim CompanyPath As String
Dim AcombaPath As String
Dim Password As String
Dim Exist, iError As Long

'Access path to the company's files to open
CompanyPath = "C:\F1000.dta\DemoSDK_EN"
'Access path to Acomba registration cards
AcombaPath = ""

'User's password
Password = "DEMO"

'Checks whether or not the company to open exists
Exist = Acomba.CompanyExists(CompanyPath)
If Exist <> 0 Then

'Opens the Demo company
iError = Acomba.OpenCompany(AcombaPath, CompanyPath)
If iError = 0 Then

'Finds the user "Denise" in order to obtain
'her CardPos
UserIndex.UsNumber = "Supervisor"
iError = Acomba.FindKey(UserIndex, 1)
If iError = 0 Then

'Connects the "Denise" user using her password
iError = Acomba.LogCurrentUser(UserIndex.UsCardPos, Password)
If iError = 0 Then

MsgBox("User connection successfully completed.")
Else
MsgBox("Error: " & Acomba.GetErrorMessage(iError))
End If
Else
MsgBox("Error: " & Acomba.GetErrorMessage(iError))
End If
Else
MsgBox("Error: " & Acomba.GetErrorMessage(iError))
End If
Else
MsgBox("Invalid company access path.")
End If
End Sub

Could anybody tell me what did I miss? Thanks

Jenny
avatar
hench
Nombre de messages : 163
Date d'inscription : 30/12/2008

Fiche d'Entreprise
Nom de l'entreprise:

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 11:30
Might be a stupid question,

Did you start the SDK session first?

Code:


Dim AcoSDKInt As New AcoSDK.AcoSDKX
Dim Version, Error As Long

Version = AcoSDKInt.VaVersionSDK

Error = AcoSDKInt.Start(Version)
If Error = 0 Then
 ' rest of the process
Else

MsgBox "Erreur: " & Acomba.GetErrorMessage(Error)
End If
   

A little hint for the forum usage : please, surround your code with [code ]put the code here[/code ] tags.
(without the extra blank before the ending bracket)

This makes it easier to read!

There's a button achieving this for your in the text editor toolbar.

That's a starter Smile

Good luck,

hench
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 12:08
Thank you so much!

I added SDK session start, but I still get the same error.

I am using demo version and checked my demo is not expired.

Here is the modified code. What I can do?
Code:

  Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim AcoSDKInt As New AcoSDK.AcoSDKX
        Dim iVersion As Long
        'Interface declarations
        Dim Acomba As New AcoX0127.AcombaX
        Dim UserIndex As New AcoX0127.UserKey

        'Variable declarations 
        Dim CompanyPath As String
        Dim AcombaPath As String
        Dim Password As String
        Dim Exist, iError As Long

        'Access path to the company's files to open
        CompanyPath = "C:\F1000.dta\DemoSDK_EN"
        'Access path to Acomba registration cards
        AcombaPath = ""

        'User's password
        Password = "DEMO"

        iVersion = AcoSDKInt.VaVersionSDK

        iError = AcoSDKInt.Start(iVersion)

        If iError = 0 Then
            'Checks whether or not the company to open exists
            Exist = Acomba.CompanyExists(CompanyPath)
            If Exist <> 0 Then

                'Opens the Demo company
                iError = Acomba.OpenCompany(AcombaPath, CompanyPath)
                If iError = 0 Then

                    'Finds the user "Denise" in order to obtain
                    'her CardPos
                    UserIndex.UsNumber = "Supervisor"
                    iError = Acomba.FindKey(UserIndex, 1)
                    If iError = 0 Then

                        'Connects the "Denise" user using her password
                        iError = Acomba.LogCurrentUser(UserIndex.UsCardPos, Password)
                        If iError = 0 Then

                            MsgBox("User connection successfully completed.")
                        Else
                            MsgBox("Error: " & Acomba.GetErrorMessage(iError))
                        End If
                    Else
                        MsgBox("Error: " & Acomba.GetErrorMessage(iError))
                    End If
                Else
                    MsgBox("Error: " & Acomba.GetErrorMessage(iError))
                End If
            Else
                MsgBox("Invalid company access path.")
            End If
        Else

            MsgBox("Erreur: " & Acomba.GetErrorMessage(iError))
        End If
    End Sub

Jenny
avatar
hench
Nombre de messages : 163
Date d'inscription : 30/12/2008

Fiche d'Entreprise
Nom de l'entreprise:

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 12:26
My bad


I just noticed a a mistake on the FindKey call parameters:

FindKey method header :
Code:

Int FindKey( Int Index, WordBool GetCard )

Values:

Index parameter should be in the range of 1 to 7 :
(Here's a sample from the User interface index list in the help file)

Index 1 = PKey_UsNumber

Index 2 = Key_UsLastName + PKey_UsNumber

[...]

Index 7 = Key_UsProfileType + Key_UsLastName + Key_UsNumber


In your code you used UserIndex as the first parameter for calling the FindKey method, which is declared as a User object !

Code:


Acomba.FindKey(UserIndex, 1)


So, change "UserIndex" for 1 should do the trick!

hench
avatar
hench
Nombre de messages : 163
Date d'inscription : 30/12/2008

Fiche d'Entreprise
Nom de l'entreprise:

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 12:51
Last thing I see for now would be to change these line

Code:

Dim Acomba As New AcoX0127.AcombaX
Dim UserIndex As New AcoX0127.UserKey

to

Code:

Dim Acomba As New AcoSDK.AcombaX
Dim UserIndex As New AcoSDK.UserKey

at the top of your code !

bye!

hench
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 13:09
hench a écrit:Last thing I see for now would be to change these line

Code:

Dim Acomba As New AcoX0127.AcombaX
Dim UserIndex As New AcoX0127.UserKey

to

Code:

Dim Acomba As New AcoSDK.AcombaX
Dim UserIndex As New AcoSDK.UserKey

at the top of your code !

bye!

hench

UserKey is not a member of AcoSDK. Also FindKey is not a method of AcoSDK neither.
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 13:12
I tried change the code from
Code:
iError = Acomba.FindKey(UserIndex, 1)
to
Code:
iError = Acomba.FindKey(1, 1)

It didn't crash, but it ended the program completely.
Accord to vb reference, FindKey is defined as
Code:
Public Overridable Function FindKey(ByVal KeyInterface As Object, ByVal Index As Integer) As Integer
    Member of: AcoX0127.AcombaX


The first parameter was an object, also, If I don't put the object, how it knows which table I would like to search? I find this in sample code everywhere, for example search a customer, it uses
Code:
Error = Acomba.FindKey(CustomerIndex, 1)

Jenny
avatar
hench
Nombre de messages : 163
Date d'inscription : 30/12/2008

Fiche d'Entreprise
Nom de l'entreprise:

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 13:17
Ah ! LOL! It Jumped to my eyes !

Call FindKey using the User object

Code:

 
UserIndex.FindKey(1, True)



avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 13:21
hench a écrit:Ah ! LOL! It Jumped to my eyes !

Call FindKey using the User object

Code:

 
UserIndex.FindKey(1, True)



FindKey is not a member of UserIndex.

Jenny
avatar
hench
Nombre de messages : 163
Date d'inscription : 30/12/2008

Fiche d'Entreprise
Nom de l'entreprise:

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 13:32
What version of VB is this ?
I tested the example code using good ol' VB6, went fine.

Following the logic of FindKey definition, FindKey(UserIndex, 1) should then be working great. Got a bit of misunderstanding on my side from the beginning, I beg your pardon for that.

Hmm,.. Did you test out each step of the way separately ?
Does it correctly Start first ??
1. variable AcombaPath needs a value also, should be pointing to where the main executable is
ex : "c:\fortune"

2. Did you check if DLLs are properly registered ?

FindKey method should belong to all data interfaces ....




Dernière édition par hench le Mer 15 Déc 2010 - 13:58, édité 1 fois
PlanteG
PlanteG
Nombre de messages : 1024
Ville : Québec
Date d'inscription : 11/07/2007

Fiche d'Entreprise
Nom de l'entreprise: Informatique Gilles Plante
http://ingp.ca

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 13:50
I have never program such code, but looking at the SDK documentation, here are my conclusions:

  • since you're looking for a user, the FindKey must be applied to a User Interface object
  • the object has to be initialized before calling FindKey
Here is the example code from the documentation, hoping it works right as is:

Code:
Sub LogUser()

'Déclarations

Dim AcoSDKInt As New AcoSDK.AcoSDKX

Dim UserInt As New AcoSDK.User

Dim Version As Long

Dim Error As Long

Dim MotDePasse As String

'Get the most recent version for the SDK

Version = AcoSDKInt.VaVersionSDK

'Start using the SDK with the version

Error = AcoSDKInt.Start(Version)

'No error the proceed

If Error = 0 Then

'Password for user "Supervisor"

MotDePasse = "Demo"

'Initialize user number to "Supervisor"

UserInt.PKey_UsNumber = "Supervisor"  ' In your case "Denise", the object is initialized

'Look for user "Supervisor" in index 1 to get

'it's CardPos

Error = UserInt.FindKey(1, True)

If Error = 0 Then

'Connect "Supervisor" with is CardPos and Password

Error = Acomba.LogCurrentUser(UserInt.Key_UsCardPos, MotDePasse)

If Error = 0 Then

MsgBox ("Connexion de l'usager complétée avec succès.")

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

       

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

End Sub

Sorry for the formatting, but the indentation didn't make it through Crying or Very sad .
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 14:10
hench a écrit:What version of VB is this ?
I tested the example code using good ol' VB6, went fine.

Following the logic of FindKey definition, FindKey(UserIndex, 1) should then be working great. Got a bit of misunderstanding on my side from the beginning, I beg your pardon for that.

Hmm,.. Did you test out each step of the way separately ?
Does it correctly Start first ??
1. variable AcombaPath needs a value also, should be pointing to where the main executable is
ex : "c:\fortune"

2. Did you check if DLLs are properly registered ?

FindKey method should belong to all data interfaces ....


1. I use vs 2003 and vs 2008, both I got no luck.
2. I tested step by step and find open company file is fine.
3. Since I use demo version, I cannot put value to AcombaPath. According to your document, I could just leave it blank.
4. I registered DLLs already.
5. FindKey method only belongs to AcoX0127.AcombaX.
6. All my code is from 'Acomba SDK Help' sample file come with SDK download.

Jenny
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 14:17
PlanteG a écrit:I have never program such code, but looking at the SDK documentation, here are my conclusions:

  • since you're looking for a user, the FindKey must be applied to a User Interface object
  • the object has to be initialized before calling FindKey
Here is the example code from the documentation, hoping it works right as is:

Code:
Sub LogUser()

'Déclarations

Dim AcoSDKInt As New AcoSDK.AcoSDKX

Dim UserInt As New AcoSDK.User

Dim Version As Long

Dim Error As Long

Dim MotDePasse As String

'Get the most recent version for the SDK

Version = AcoSDKInt.VaVersionSDK

'Start using the SDK with the version

Error = AcoSDKInt.Start(Version)

'No error the proceed

If Error = 0 Then

'Password for user "Supervisor"

MotDePasse = "Demo"

'Initialize user number to "Supervisor"

UserInt.PKey_UsNumber = "Supervisor"  ' In your case "Denise", the object is initialized

'Look for user "Supervisor" in index 1 to get

'it's CardPos

Error = UserInt.FindKey(1, True)

If Error = 0 Then

'Connect "Supervisor" with is CardPos and Password

Error = Acomba.LogCurrentUser(UserInt.Key_UsCardPos, MotDePasse)

If Error = 0 Then

MsgBox ("Connexion de l'usager complétée avec succès.")

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

       

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

End Sub

Sorry for the formatting, but the indentation didn't make it through Crying or Very sad .

I run the code you gave to me, now It is not crashing. I got error "Erreur: Cette application n'est pas installée"

Jenny
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 14:43
PlanteG a écrit:I have never program such code, but looking at the SDK documentation, here are my conclusions:

  • since you're looking for a user, the FindKey must be applied to a User Interface object
  • the object has to be initialized before calling FindKey
Here is the example code from the documentation, hoping it works right as is:

Code:
Sub LogUser()

'Déclarations

Dim AcoSDKInt As New AcoSDK.AcoSDKX

Dim UserInt As New AcoSDK.User

Dim Version As Long

Dim Error As Long

Dim MotDePasse As String

'Get the most recent version for the SDK

Version = AcoSDKInt.VaVersionSDK

'Start using the SDK with the version

Error = AcoSDKInt.Start(Version)

'No error the proceed

If Error = 0 Then

'Password for user "Supervisor"

MotDePasse = "Demo"

'Initialize user number to "Supervisor"

UserInt.PKey_UsNumber = "Supervisor"  ' In your case "Denise", the object is initialized

'Look for user "Supervisor" in index 1 to get

'it's CardPos

Error = UserInt.FindKey(1, True)

If Error = 0 Then

'Connect "Supervisor" with is CardPos and Password

Error = Acomba.LogCurrentUser(UserInt.Key_UsCardPos, MotDePasse)

If Error = 0 Then

MsgBox ("Connexion de l'usager complétée avec succès.")

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

       

Else

MsgBox ("Erreur: " & Acomba.GetErrorMessage(Error))

End If

End Sub

Sorry for the formatting, but the indentation didn't make it through Crying or Very sad .

I have a question here: if you don't open a company file, where will you log in?

Jenny
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 14:51
I finally make it work, here is the code
Code:

    Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim AcoSDKInt As New AcoSDK.AcoSDKX

        Dim UserInt As New AcoSDK.User

        Dim Version As Long

        Dim Exist, iError As Long

        Dim CompanyPath As String
        Dim AcombaPath As String
        Dim MotDePasse As String
        Dim Acomba As New AcoSDK.AcombaX
        'Get the most recent version for the SDK

        Version = AcoSDKInt.VaVersionSDK

        'Start using the SDK with the version

        iError = AcoSDKInt.Start(Version)

        'No error the proceed
        CompanyPath = "C:\F1000.dta\DemoSDK_EN"
        'Access path to Acomba registration cards
        AcombaPath = ""
        If iError = 0 Then
            'Checks whether or not the company to open exists
            Exist = Acomba.CompanyExists(CompanyPath)
            If Exist <> 0 Then

                'Opens the Demo company
                iError = Acomba.OpenCompany(AcombaPath, CompanyPath)
                If iError = 0 Then

                    'Password for user "Supervisor"

                    MotDePasse = "Demo"

                    'Initialize user number to "Supervisor"

                    UserInt.PKey_UsNumber = "Supervisor"  ' In your case "Denise", the object is initialized

                    'Look for user "Supervisor" in index 1 to get

                    'it's CardPos

                    iError = UserInt.FindKey(1, True)

                    If iError = 0 Then

                        'Connect "Supervisor" with is CardPos and Password

                        iError = Acomba.LogCurrentUser(UserInt.Key_UsCardPos, MotDePasse)

                        If iError = 0 Then

                            MsgBox("Connexion de l'usager complétée avec succès.")

                        Else

                            MsgBox("Erreur: " & Acomba.GetErrorMessage(iError))

                        End If

                    Else

                        MsgBox("Erreur: " & Acomba.GetErrorMessage(iError))

                    End If



                Else

                    MsgBox("Erreur: " & Acomba.GetErrorMessage(iError))
                End If
            Else
                MsgBox("Invalid company access path.")
            End If
        Else

            MsgBox("Erreur: " & Acomba.GetErrorMessage(iError))
        End If


    End Sub

Now the issue is that this way is different from the way in help file. Do you have any document giving samples in this way of programming. Since I have to add customer, add invoice, and a lot of things, and it is really a long way, samples really help.
avatar
hench
Nombre de messages : 163
Date d'inscription : 30/12/2008

Fiche d'Entreprise
Nom de l'entreprise:

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 15:08
Yep, this code figures litteraly in the help file, didn't think this would work in visual studio. Thanks PlanteG for that !!

You will want to download SDK help file which is included in both AcoSDK packages available on Fortsum website :

http://www.fortsum.com/Accueil/AccesDeveloppeur/Telechargement/tabid/302/language/en-US/Default.aspx

Good luck,
Glad you could make it!

hench
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 15:17
hench a écrit:Yep, this code figures litteraly in the help file, didn't think this would work in visual studio. Thanks PlanteG for that !!

You will want to download SDK help file which is included in both AcoSDK packages available on Fortsum website :

http://www.fortsum.com/Accueil/AccesDeveloppeur/Telechargement/tabid/302/language/en-US/Default.aspx

Good luck,
Glad you could make it!

hench
The link you gave to me is the one I downloaded. The samples and explanations gave me the way my code was, which is not working for me. Instead of using AcoSDK, It all use AcoX0118, which brings different way to access data files.

Jenny
avatar
hench
Nombre de messages : 163
Date d'inscription : 30/12/2008

Fiche d'Entreprise
Nom de l'entreprise:

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 15:35
Code you just provided figures in 0C_ACOX.HLP help file.
Summary > Visual Basic examples

And so there is a bunch of others examples for you.

I gotta precise I've been using the french version of the help file, no clue if the english version has them all, I would presume so.



Wow, I reckon today's conversation has been quite confusing, would it be because I'm working on 3 cases at once... in 3 different fields!

Shame on my brain !

Have a good one,
avatar
JennyZou
Nombre de messages : 25
Date d'inscription : 15/12/2010

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 15:42
hench a écrit:Code you just provided figures in 0C_ACOX.HLP help file.
Summary > Visual Basic examples

And so there is a bunch of others examples for you.

I gotta precise I've been using the french version of the help file, no clue if the english version has them all, I would presume so.



Wow, I reckon today's conversation has been quite confusing, would it be because I'm working on 3 cases at once... in 3 different fields!

Shame on my brain !

Have a good one,

Thank you very much for your time.
I found I went to the wrong help file. 0C_AcoSDK.hlp is the good one. I ignore it in the beginning because I thought it was a French version of 09_Acox.hlp, which is not good for me. Thanks again.

Jenny
Jeremie
Jeremie
Nombre de messages : 123
Date d'inscription : 11/08/2010

Fiche d'Entreprise
Nom de l'entreprise:
http://bourgeois-sc.com

Crash on FindKey Empty Re: Crash on FindKey

Mer 15 Déc 2010 - 15:45
Hi.

The exemple in the official documentation it's just to old.
VB6 was depreciated since 2001 ... if is not 2000.

And in some case the code was not totaly usefull.

I have created some function to save product and invoice in Acomba, but i use de ODBC.
The exemple for create Invoice dont work, this need approximatly 4 weeks with a lot of email to the ODBC help ....

Finnaly he give me a supposed .Net function and have use hem to create make my function functional.

Anyway ... i hope the new version of Acomba was just beter.

And sorry for my english.

Majid_QC aime ce message

Contenu sponsorisé

Crash on FindKey Empty Re: Crash on FindKey

Revenir en haut
Sujets similaires
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum