I'm having a problem in attempting to insert a record into a Navision .FDB database table using Visual Studio.NET and C#. When I try to insert a record using the CFRONT.dll AssignField() function, I get a "'type mismatch' error from mscorlib.dll".
Some people recommend using long instead of int, but CFRONTClass.AssignField only takes int as inputs. When I try it I get the following error message: "The best overloaded method match for 'CFRONTLib.CFRONTClass.AssignField(int, int, int, ref object)' has some invalid arguments"
Others have recommended CFRONT proxy component for .NET usage v1.2 which I have also tried. Using Interop.netCFRONT2_Prj supposedly allows for 'AssignField_AsText', ..Boolean, ..Date, ..Decimal,..Integer, and ..Time.
When I try this I get the error message: "Object variable or With block variable not set". I'm setting the object variable the same way that I set the object variable for CFRONTClass using Interop.CFRONTLib
I've noticed many other similar un-answered posts. I'm hoping someone has the expertise and can reply with meaningful specifics.
0
Comments
here's the class I use:
Private oCFRONT As CFRONTLib.CFRONT 'refrence CFRONT.ocx
Private bHideError As Boolean
Private lFieldNo As Long
Private lAllocRec As Long
Private lGetFieldData As Variant
'connection
'
Private mServer As String
Private mNetType As String
Private mUserID As String
Private mPWD As String
Private mCompany As String
Public Sub Activate()
Set oCFRONT = New CFRONTLib.CFRONT
bHideError = True
oCFRONT.HideError = bHideError
End Sub
Public Sub Deactivate()
Set oCFRONT = Nothing
End Sub
Public Property Get HideError() As Boolean
HideError = bHideError
End Property
Public Property Let HideError(ByVal bvalue As Boolean)
bHideError = bvalue
End Property
Public Sub AllowRecordNotFound()
oCFRONT.AllowRecordNotFound
End Sub
Public Sub AllowRecordExists()
oCFRONT.AllowRecordExists
End Sub
Public Sub AllowKeyNotFound()
oCFRONT.AllowKeyNotFound
End Sub
Public Sub OpenDatabase(sDB As String, lCache As Long, bUseCommitCache As Boolean)
oCFRONT.OpenDatabase sDB, lCache, bUseCommitCache
End Sub
Public Sub ConnectServer(ByVal sServer As String, ByVal sNetType As String)
mServer = sServer
mNetType = sNetType
oCFRONT.ConnectServer mServer, mNetType
End Sub
Public Sub DisconectServer()
oCFRONT.DisconnectServer
End Sub
Public Sub Login(ByVal sUserID As String, ByVal sPWD As String)
mUserID = sUserID
mPWD = sPWD
oCFRONT.Login mUserID, mPWD
End Sub
Public Sub OpenCompany(ByVal sCompany As String)
mCompany = sCompany
oCFRONT.OpenCompany mCompany
End Sub
Public Sub OpenTable(lhTable As Long, lTableNo As Long)
oCFRONT.OpenTable lhTable, lTableNo
End Sub
Public Sub BWT()
oCFRONT.BWT
End Sub
Public Sub EWT()
oCFRONT.EWT
End Sub
Public Sub AWT()
oCFRONT.AWT
End Sub
Public Sub CloseDatabase()
oCFRONT.CloseDatabase
End Sub
Public Sub CloseCompany()
oCFRONT.CloseCompany
End Sub
Public Sub FindRec(lhTable As Long, lhRec As Long, sSearch As String)
oCFRONT.FindRec lhTable, lhRec, sSearch
End Sub
Public Sub FreeRec(lhRec As Long)
oCFRONT.FreeRec lhRec
End Sub
Public Sub CloseTable(lhTable As Long)
oCFRONT.CloseTable lhTable
End Sub
Public Sub InitRec(lhTable As Long, lhRec As Long)
oCFRONT.InitRec lhTable, lhRec
End Sub
Public Sub AssignField(lhTable As Long, lhRec As Long, lFieldNo As Long, vntData)
oCFRONT.AssignField lhTable, lhRec, lFieldNo, vntData
End Sub
Public Function InsertRec(lhTable As Long, lhRec As Long) As Boolean
InsertRec = oCFRONT.InsertRec(lhTable, lhRec)
End Function
Public Function ModifyRec(lhTable As Long, lhRec As Long) As Boolean
ModifyRec = oCFRONT.ModifyRec(lhTable, lhRec)
End Function
Public Function AllocRec(lhTable As Long) As Long
lAllocRec = oCFRONT.AllocRec(lhTable)
AllocRec = lAllocRec
End Function
Public Function FieldNo(lhTable As Long, sFieldName As String)
lFieldNo = oCFRONT.FieldNo(lhTable, sFieldName)
FieldNo = lFieldNo
End Function
Public Function GetFieldData(lhTable As Long, lhRec As Long, lFieldNo)
lGetFieldData = oCFRONT.GetFieldData(lhTable, lhRec, lFieldNo)
GetFieldData = lGetFieldData
End Function