Problem with CFRONT OCX !! HELP ME

jyotsnas
Member Posts: 62
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 !!
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 !!!
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:
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 !!

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 !!!

______Doubt is the father of Invension_______
0
Comments
-
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.0
-
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_______0 -
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 JainAjay Jain
UK0 -
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_______0 -
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
UK0 -
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.0 -
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.0 -
@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
Guido0 -
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?
-Steve0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions