Solved
Late binding
Posted on 2004-09-13
Hi!
I have the following code that needs to be translated into C#(no problems) and used with late binding(???)
A reference to gbaapi.exe is added in the project.
Dim oGBA As Object
Dim RetValue
'Creates the GBA object
Set oGBA = CreateObject("GBAAPI.GBA")
'Specifies the data location of the chosen client
RetValue = oGBA.SetClientPath("c:\program files\mamut\data\client\000\001")
If RetValue = 0 Then
Response = MsgBox("The path to the client data location is incorrect.", 0, "MAMUT API")
End If
'Adds the contact object to the GBA object
Dim oContact
Set oContact = oGBA.CreateContactObject()
If TypeName(oContact) <> "Object" Then
Response = MsgBox("An error occurred during the creation of the Contact object.", 0, "MAMUT API")
End If
'Create a new contact
RetValue = oContact.CreateNew()
If RetValue = 0 Then
Response = MsgBox("An error occurred during creation of new contact.", 0, "MAMUT API")
End If
'Make changes to a contact (after it is retrieved/created)
oContact.ContName = "Mamut Ltd"
oContact.Street = "90 Long Acre"
oContact.City = "London"
oContact.Zipcode = "WC2E 9RZ"
oContact.Data56 = 1
'Save a contact
RetValue = oContact.Save()
If RetValue = 0 Then
Response = MsgBox("An error occurred during saving of contact.", 0, "MAMUT API")
End If
I tried this:
public class Faktura
{
public bool CreateFaktura()
{
gbaapi.gba GBA = new gbaapi.gba();
if(GBA.setclientpath(@"\\SERVER\Mamut\Data\Client\000\001").ToString()!="0")
{
gbaapi.contactClass oContact = (gbaapi.contactClass)GBA.createcontactobject();
int RetValue = oContact.createnew();
if(RetValue==0)
{
oContact.contname = "Mamut Ltd";
oContact.street = "90 Long Acre";
oContact.city = "London";
oContact.zipcode = "WC2E 9RZ";
oContact.data56 = 1;
oContact.save()
return true;
}
else
return false;
}
else
return false;
}
}
But I keep getting this:
No overload for method 'createnew' takes '0' arguments
public virtual new System.Object createnew ( System.Int32 lnContid )
Member of gbaapi.contactClass
The manual says nothing about create new needs an argument:
Creates a new contact. All properties of the Contact object are now blank (default from the client), except Contid to which the next available number in the number series is assigned. If the requested customer number is already in use, the next available number will be assigned.
Returns the value 0 if an error occurs; otherwise returns the value 1.
What am I doing wrong?