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:
Comments
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
UK
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
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.
UK
Use dll loading, then you will be albe load more than one instance of cfront.
If it was hard to write, it should be hard to understand.
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
-Steve