Small bit of code from VB6 to VB.net - desperate need of help

  • Thread starter Thread starter garyusenet
  • Start date Start date
G

garyusenet

I have been trying to interface with my act database using .net and act
api's. I was originally using c# but it wouldn't connect to the
database. I tried VB in desperation and it is connecting!

Now i have hit another problem and i'm sure its down to the fact that
the code was written years ago, and needs a bit of modification for
..net can you take a look at these 12 lines of code and let me know how
to get it to work in .net please...

dim objDatabase as object
Set objDatabase = CreateObject("ACTOLE.DATABASE")
objDatabase.Open dbname

by changing the last line to : objDatabase.Open("path\database.dbf")
I've managed to open the database with no problem. I know this because
I used objDatabase.LastError and it returned an error code of 0 which
means success. And before in C# I was getting error code 87 which means
can't connect.
---
Now these next eight lines seem to be the problem, please have a look
and see if you can help me. The exame code continues as follows...

Dim tavleObject As Object
Set tableObject = objDatabase.CONTACT

tableObject.MoveFirst

(the above line generates the first error, and complains about a Null
reference exception being unhandled)

dim strOutput as String
strOutput = tableObject.Data(CF_Name)

the above line doesn't work in .net either and this is what is giving
me the problem I think...

I look forward to your comments

Gary
 
dim table i mean sorry about the poor typing, but i'm late for a
meeting, ill check again in an hour and hopefully there will be some
good input from you experts!
 
What happened to the Interop library you generated and why aren't you using
it?

Add it as a reference and you should be in business.

Dim objDatabase As New ACTOLE.DATABASE

objDatabase.Open(dbname)

Dim tableObject As ACTOLE.CONTACT = objDatabase.CONTACT

tableObject.MoveFirst()

Dim strOutput as String = tableObject.Data(CF_Name)

etc. ....
 
Hi Stephany i'm a bit confused to tell you the truth.
So far i've added act.dll which is the file tlbimp created from act.tlb
(act.tlb is the original tlb provided with act) - and i've also added
actevent.ocx. I've done this by right clicking on reference in solution
explorer and choosing 'add reference'

The source code isn't working. any ideas?
 
Back
Top