Problems with CFRONT and Visual Basic

Tim81Tim81 Member Posts: 68
Hi,

i have a big problem. We need to change C/Front from the OCX to DLL.

So i made this little test script as a macro in Visio (where it is needed finally)
Private Declare Sub DBL_Init Lib "cfront.dll" ()
Private Declare Sub DBL_Exit Lib "cfront.dll" ()
Private Declare Sub DBL_ConnectServerAndOpenDatabase Lib "cfront.dll" (NDBCDriverName, ServerName, NetType, DatabaseName, CacheSize, UseCommitCache, UseNTAuthentication, UserID, PassWord)

Private Sub ConnectToDatabaseDBL()
  
    Dim DatabaseName As String
    Dim DriverName As String
    Dim ServerName As String
    Dim NetType As String
    Dim UserID As String
    Dim PassWord As String
    
    DatabaseName = "database.fdb"
    DriverName = "NDBCN"
    ServerName = "localhost"
    NetType = "tcp"
    UserID = "super"
    PassWord = ""
  
    Call DBL_Init
    Call DBL_ConnectServerAndOpenDatabase(DriverName, ServerName, NetType, DatabaseName, 10000, 1, 0, UserID, PassWord)
    Call DBL_Exit
       
    Exit Sub
            
End Sub

If it comes to the ConnectServerAndOpenDatabase function it always says something like: "The OS cannot load the DLL "path\nc_□@.dll"".

But the nc_tcp.dll, nc_tcps.dll, nc_netb exists. What is the problem??

Comments

  • Tim81Tim81 Member Posts: 68
    So, i solved the first problem. Now the code looks like this:
    Private Declare Sub DBL_Init Lib "cfront.dll" ()
    Private Declare Sub DBL_Exit Lib "cfront.dll" ()
    Private Declare Sub DBL_ConnectServerAndOpenDatabase Lib "cfront.dll" ( _
        ByVal NDBCDriverName As String, _
        ByVal ServerName As String, _
        ByVal NetType As String, _
        ByVal DatabaseName As String, _
        ByVal CacheSize As Integer, _
        ByVal UseCommitCache As Boolean, _
        ByVal UseNTAuthentication As Boolean, _
        ByVal UserID As String, _
        ByVal PassWord As String)
        
    Private Sub ConnectToDatabaseDBL()
      
        Dim DriverName As String
        Dim ServerName As String
        Dim NetType As String
        Dim DatabaseName As String
        Dim CacheSize As Integer
        Dim UseCommitCache As Boolean
        Dim UseNTAuthentication As Boolean
        Dim UserID As String
        Dim PassWord As String
        
        DriverName = "NDBCN"
        ServerName = "localhost"
        NetType = "tcp"
        DatabaseName = "database.fdb"
        CacheSize = "10000"
        UseCommitCache = False
        UseNTAuthentication = False
        UserID = "super"
        PassWord = ""
      
        Call DBL_Init
        Call DBL_ConnectServerAndOpenDatabase(DriverName, ServerName, NetType, DatabaseName, CacheSize, UseCommitCache, UseNTAuthentication, UserID, PassWord)
        Call DBL_Exit
        
        DatabaseConnected = True
        
        Exit Sub
                
    End Sub
    
    But now he always sais: "UserID and/or Password not correct." This is the failure message from navision. So he seems to connect to the DB, but he always denies the access.
    Any ideas?

    Thx in advance
  • kinekine Member Posts: 12,562
    have the user permission for system object C/Front?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Tim81Tim81 Member Posts: 68
    Hi,

    of course I have the permissions. If you try to use a license without that permission, you get a different error message.

    But I heard that the cfront.dll is not working with Visual Basic at all.

    There are two different "Calling Conventions".
    a) _CDECL (C++, Delphi, etc.) The cfront.dll is compiled this way.
    b) StdCall (VisualBasic)
    So there is no possibility to use the dll with Visual Basic.

    But we got the OCX work again. So we will use this further.

    Thx
    Tim
Sign In or Register to comment.