Code to login without using the login form

Discussions relating to breakout scripting, .NET and COM programming with Jiwa objects.

Code to login without using the login form

Postby Mike.Sheen » Thu Jun 18, 2009 10:05 am

Here's a demonstration on how you can establish a connection to Jiwa using code, which does not rely on the login form.

This technique is useful when writing utilities or services which do not require interaction with the user.

It's pretty simple - but keep in mind connecting to the database is only the first step if you wish to use our business logic objects - most of our objects require a database object, a system profile object, a JiwaLib object and a JiwaCommonLib object.

Code: Select all
Public Function GetDatabase(ByVal ServerName As String, ByVal DatabaseName As String, ByVal SQLLogin As String, ByVal SQLPassword As String, ByVal JiwaLogin As String, ByVal JiwaPassword As String, ByVal XMLProfileFile As String) As JiwaODBC.database
        Dim Database As New JiwaODBC.database
        Database.ConnectionDetails = "Provider=SQLOLEDB; Data Source=" & ServerName & ";Initial Catalog=" & DatabaseName & ";User ID=" & SQLLogin & ";Password=" & SQLPassword & ";"

        Database.IniFile = XMLProfileFile

        If Database.MakeConnections(0) Then
            If Database.DoLogOn(JiwaLogin, JiwaPassword) = False Then
                Throw New Exception(Database.ErrorMessage)
            Else
            End If
        Else
            Throw New Exception(Database.ErrorMessage)
        End If

        Return Database

    End Function


And here's the code to use the above function :

Code: Select all
        Dim Database As JiwaODBC.database
        Dim SystemProfile As JiwaSysProfile.clsSysProfile

        Database = GetDatabase("JiwaMike", "JiwaDemo_060513", "sa", "jiwa", "Admin", "password", "C:\Program Files\Jiwa Financials\Jiwa\Jiwa.XML")

        ' Create a system profile object, and load the xml file
        SystemProfile = New JiwaSysProfile.clsSysProfile
        SystemProfile.Load(Database.IniFile)

        ' You may like to create other support objects at this point - eg : JiwaCommonLib, JiwaLib, JiwaSearch, etc

        ' Do your processing here...

        Database.BreakConnections()
        Database = Nothing

Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 5 guests