NAV 5.0 SP1 and CFRONT vb.Net Example (VS 2008 SP1)
wreese@guardian.com
Member Posts: 2
Hello everyone,
I've been searching for a good cfront example to simply connect to our NAV database -- alas, none to be found. Anyway, I converted one of the C# examples and finally got this to work. Of course, you'll need to include the Microsoft.Navision.CFront.CFrontDotNet wrapper from the SDK folder as a reference to VS 2008 and follow the readme guidelines for placing the cfront*.dlls. You'll also need to change the server name, etc. to suite your needs.
All this example does is display the name of a customer in a message box, but it will get you started. It uses windows authentication while I'm testing on my laptop (you can tweak the parameters to ConnectServerAndOpenDatabase()). If anyone finds more vb.net examples out there (not vb6) or a better vb.net way to perform a simple connect like below, please let me know....
Hope this helps someone and by the way, appreciate all the posts out there -- mibuso is a great resource!
See ya,
Bill
I've been searching for a good cfront example to simply connect to our NAV database -- alas, none to be found. Anyway, I converted one of the C# examples and finally got this to work. Of course, you'll need to include the Microsoft.Navision.CFront.CFrontDotNet wrapper from the SDK folder as a reference to VS 2008 and follow the readme guidelines for placing the cfront*.dlls. You'll also need to change the server name, etc. to suite your needs.
All this example does is display the name of a customer in a message box, but it will get you started. It uses windows authentication while I'm testing on my laptop (you can tweak the parameters to ConnectServerAndOpenDatabase()). If anyone finds more vb.net examples out there (not vb6) or a better vb.net way to perform a simple connect like below, please let me know....
Hope this helps someone and by the way, appreciate all the posts out there -- mibuso is a great resource!
See ya,
Bill
Public Class frmCFront
Const SERVER_NAME As String = "PC001799\SQLDEV"
Const DATABASE_NAME As String = "GAPI5"
Const COMPANY_NAME As String = "Guardian Automotive Products"
Const TBL_Customer As Integer = 18
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CFR As Microsoft.Navision.CFront.CFrontDotNet
Dim iTable As Integer, iRec As Integer
Dim navtxtName As Microsoft.Navision.CFront.NavisionText
Microsoft.Navision.CFront.CFrontDotNet.DriverType = _
Microsoft.Navision.CFront.NavisionDriverType.Sql
CFR = Microsoft.Navision.CFront.CFrontDotNet.Instance
Try
CFR.ConnectServerAndOpenDatabase(SERVER_NAME, _
Microsoft.Navision.CFront.NavisionNetType.SqlDefault, _
DATABASE_NAME, 10000, False, True, "", "")
CFR.OpenCompany(COMPANY_NAME)
iTable = CFR.OpenTable(TBL_Customer)
iRec = CFR.AllocRecord(iTable)
' Set filter on a "Customer"."No."
CFR.SetFilter(iTable, CFR.FieldNo(iTable, "No."), "=2504")
' Find the first record
CFR.FindFirstRecord(iTable, iRec)
' Obtain "Customer"."Name"
navtxtName = CFR.GetFieldData(iTable, iRec, CFR.FieldNo(iTable, "Name"))
MsgBox(navtxtName.ToString)
CFR.FreeRecord(iRec)
CFR.CloseTable(iTable)
CFR.CloseCompany()
CFR.CloseDatabase()
CFR.DisconnectServer()
Catch ex As Exception
MsgBox(ex.Message)
Finally
CFR.Dispose()
CFR = Nothing
End Try
End Sub
End Class
Bill Reese
Guardian Aftermarket IT Manager
Guardian Aftermarket IT Manager
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 250 Dynamics CRM
- 102 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions