AssignField Fails in .NET
 
            
                
                    bramante                
                
                    Member Posts: 11                
            
                        
            
                    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.
                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
- 
            Using it inside a VB6 class wrapper, works for me.
 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 Function0
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
- 323 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
