Problem with CFRONT OCX !! HELP ME

jyotsnasjyotsnas Member Posts: 62
edited 2005-11-13 in Navision Attain
Hi All

I have been trying to get rid of this problem since yesterday and still there are so many things that i cannot make out. :x

I am developing an utility in VB 6.0 that will copy data from a table in one company in a database to another in different database.

I first tried to read data from one navision database. It worked !! :D

i copied my source and destination databases to the directory where client is installed. Now i am trying to read from source database and write the record into another. I created table handles and record handles for source and destination the tables and its fine. But when i am writing code to locate first record of source table, it says the table is empty. But there are records in the table. :shock:

This is one problem. Another problem is that - when i run this utility for the first time when i open the project, it gives me this table empty error; but when i run it next time, (without closing the project) i get error for the first statement thats written in the code. I cannot understand this. It all appeares so unreliable. :roll:

Get me through it Please !!! :cry: Or tell me another way of getting the job done. If i go for dataports, there would be one for each table. thats why i thought of an utility that would accept table no. , company name , source and destination databases and will do the job on one click. :evil:
______Doubt is the father of Invension_______

Comments

  • BobBrownBobBrown Member Posts: 17
    I can't help you with the OCX problem, but you are not limited to one table per dataport. You can add as many data items as you need to a dataport.
  • jyotsnasjyotsnas Member Posts: 62
    Thanks for the promt reply and ur suggestion. But even if i use one dataport, amount of effort remains the same. Anyways, thanks. :) . It seems to be a good solution for time being; but i have got to look after this OCX. :twisted: we can try out different ways CFRONT OCX can be used and find out how reliable it is. United effort will make it more fruitful i suppose. Anybody interested ?? 8)

    Jyotsna
    ______Doubt is the father of Invension_______
  • ajayjainajayjain Member Posts: 119
    Dear Jyotsna

    Try this code, it is working at my end.

    Dim cf As New CFRONT
    Dim TableNo As Long
    Dim TableRef As Long
    Dim FieldNo As Long
    Dim Rec As Long
    Dim Value1 As Variant
    Dim Value2 As Variant

    Set cf = CreateObject("cfront.cfrontctrl.1")
    cf.OpenDatabase "C:\Navision Database Path\Navision.fdb", 10000, False
    cf.OpenCompany "Company Name"
    TableNo = 18
    cf.OpenTable TableRef, TableNo
    Rec = cf.AllocRec(TableRef)
    cf.FindRec TableRef, Rec, "-"
    Value1 = cf.GetFieldData(TableRef, Rec, 1)
    Value2 = cf.GetFieldData(TableRef, Rec, 2)
    cf.FreeRec Rec
    cf.CloseTable TableRef
    cf.CloseCompany
    cf.CloseDatabase
    '######################################################

    cf.OpenDatabase "C:\Navision Database Path 2\Navision.fdb", 10000, False
    cf.OpenCompany "Company Name 2"
    cf.OpenTable TableRef, TableNo
    Rec = cf.AllocRec(TableRef)
    cf.BWT
    cf.InitRec TableRef, Rec
    cf.AssignField TableRef, Rec, 1, Value1
    cf.AssignField TableRef, Rec, 2, Value2
    cf.InsertRec TableRef, Rec
    cf.EWT
    cf.FreeRec Rec
    cf.CloseTable TableRef
    MsgBox "Done"

    Please Note that you have to close source database before you open destination database so store the values in the variables. You can keep both the database open if you copy the whole navision folder with another name and set path for cf and cf1 variables.

    Ajay Jain
    Ajay Jain
    UK
  • jyotsnasjyotsnas Member Posts: 62
    Dear Ajay

    I tried the code u gave me. It works. But i want both the databases open at a time so that it would allow me to read from source and put in destination database in a loop. I copied entire navision attain folder and put the two databases in each. Still its giving me error when I find("-")
    > Customer Table is empty, even when its not.

    I believe you can give me the solution still Can you give me some material that will help me explore it more deeply ???

    Thank You

    Regards
    Jyotsna
    ______Doubt is the father of Invension_______
  • ajayjainajayjain Member Posts: 119
    Dear Jyotsnas,

    first of all tell me the code i gave you last time, does it work completely
    I mean are you able to read from one database and store in another
    database.

    I have not tried for both the databases at the same time. I will try
    and let you know. I am sure if you do the same through navision server
    it will work.
    Ajay Jain
    UK
  • dbdb Member Posts: 82
    You are not able open 2 db at same time using OCX !!! Becouse ocx loads only one cfront.dll => ONE INSTANCE FOR TWO DATABASES ???
    Use dll loading, then you will be albe load more than one instance of cfront.
  • Alexey_PavlovAlexey_Pavlov Member Posts: 10
    Try to use 'SelectLatestVersion' method before opening table. This method retrueves latest (current) data in database.
    Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand.
  • guidorobbenguidorobben Member Posts: 157
    @ajayjain

    I tried your code, but this gave me the error 1406 Module 19. I also have this problem with the example cfront.xls.

    Am I missing something. I can activate the aboutbox by code, so the ocx is installed correctly.

    I must add this is the line that's a showstopper:

    cf.OpenDatabase "C:\database.fdb", 10000, False

    Guido
  • sbraninsbranin Member Posts: 18
    I am getting the Error 1406 in module 19 when I try to use the cfront.ocx to access a navision database from a vb application. I have tried everything I can think of and searched the forums for answers. What causes this?

    -Steve
Sign In or Register to comment.