Using Exact Globe DLLs in C# code

  • Thread starter Thread starter Igor-M
  • Start date Start date
I

Igor-M

Guest
Hello,


Could someone please help me with the following issue. I’ve been programming for some time in VBA (for Excel in most cases). I wrote an app that connects to the Exact Globe databases and retrieves some data from them. The app used three DLL libraries delivered by Exact (Exact Application Programmers Interface e4slayer.dll, EDL type library sysedl32.dll, Exact SDK Connection Component CSSDKConnect.dll). The way to use them in VBA code was pretty straightforward to me. All I had to do was adding the aforementioned libraries using References in VBA menu. I enclose a sample code below to visualize the use of these libraries. The issue I have is of course related to the code below. I’ve started learning C# very recently and I’ve been trying to ‘translate’ the code from VBA to C# — ie I wanted to achieve the same functionality in C# windows form app. Unfortunately, despite going through several guides on attaching external DLLs available in the Internet, I failed to do so. So, could someone please be so kind and help me with writing a correct code that will connect to the Exact (I assume it should be possible to do using the same DLLs as I used in my VBA apps).


Sub MainApp()


Dim cEDLQuery As EdlQuery


Dim sQuery As String


GlobalVariableDeclarations


ConnectToExact iError, "db_name_123", "010"


sQuery = "SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES"


Set cEDLQuery = gEDLConnection.OpenQuery(sQuery, edlClientSnapshot, edlReadOnly, edlOptDontParse)


cEDLQuery.FetchFirst


While Not cEDLQuery.EOF


' do something here


cEDLQuery.FetchNext


Wend


DisconnectFromExact


End Sub





Sub GlobalVariableDeclarations()


Public gSDKConnect As CSSDKConnect.SDKConnect


Public gSDKConnection As CSSDKConnect.SDKConnection


Public gEDLConnection As EDL.EdlConnection


Public cConnError As CSSDKConnect.SDKConnectionErrors ' 1000 – no errors


End Sub





''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


' Comments: This routine is responsible for creating a connection to


' Exact Globe databases.


'


' Arguments: None


'


' Returns: None





Public Sub ConnectToExact(ByRef Error As Integer, sServerName As String, sDataBaseName As String)


Dim sProcName As String


Dim sErrorMessage As String


Error = 0


On Error GoTo ErrHandler


Dim cConnError As CSSDKConnect.SDKConnectionErrors


Set gSDKConnect = New CSSDKConnect.SDKConnect


cConnError = gSDKConnect.ConnectDirect(sServerName, sDataBaseName, gSDKConnection)


If cConnError <> ConnNoError Then


Call MsgBox("Error connecting to database" & vbNewLine & _


"SDKConnectionError: " & cConnError, vbCritical)


GoTo ErrHandler


End If


Set gEDLConnection = gSDKConnection.Environment.Connection


Exit Sub


ErrHandler:


Error = 1





End Sub





'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


' Comments: This routine closes active connection to


' Exact Globe database.


'


' Arguments: None


'


' Returns: None


Public Sub DisconnectFromExact()





On Error GoTo ErrHandler


If Not gSDKConnection Is Nothing Then


Call gSDKConnect.Disconnect(gSDKConnection)


Set gSDKConnect = Nothing


End If


Exit Sub


ErrHandler:


MsgBox "Error disconnecting: '" & Err.Description & "' ", vbCritical + vbOKOnly, gsAPP_NAME


End Sub

-- Igor M.

Continue reading...
 

Similar threads

R
Replies
0
Views
170
Ravi Kumar12233
R
S
Replies
0
Views
123
Stuart Coutts (gtx_viper)
S
Back
Top