Using .NET, Connect to simply accounting enterprise 2009 without opening simply accounting?

Posted on 2009-07-10
Last Modified: 2013-12-11
Hi folks,

I am having a problem trying to connect to simply accounting enterprise 2009 (SAE2K9) through without first opening SAE2K9.
I need to be able to read data from some tables in simply for the purposes of bringing that data in to a 3rd party app I am
writing.  Does anyone have some sample code out there that I could use?  I've scoured google and other search engines but to no avail
and have also sought help through the simply forums.  No one seems willing to help out?  Any takers?

Thanks in advance.
Question by:sharizod
  • 2

Accepted Solution

sharizod earned 0 total points
Comment Utility
I've figured it out.  It wasn't exactly easy or well documented, but it seems to work, all without opening simply accounting!

I hope this helps someone else the heartache and pain of trying to connect.
I am going to PAQ & refund points.

Imports MySql.Data

Imports MySql.Data.MySqlClient

Public Class Form1

	Public Sub ConnectTo2Simply()


			Dim dbclient As New Simply.ConnectionManagerServiceClient.ConnectionManagerServiceClient

			Dim error2 As Simply.ConnectionManagerService.ConnectionManagerError

			Dim port As String = "13540"

			Dim host As String = "localhost"

			Dim sFileName As String = "C:\Documents and Settings\All Users\Documents\Simply\2009\Samdata\Enterprise\Universl.SAJ"

			Dim db_version As String = "16102"

			error2 = dbclient.GetConnectionInfo(sFileName, host, port)

			If error2 = Simply.ConnectionManagerService.ConnectionManagerError.Error_MySQL_NotRunning Then

				error2 = dbclient.StartClient("C:\Documents and Settings\All Users\Documents\Simply\2009\Samdata\Enterprise\Universl.SAI", "localhost")

				error2 = dbclient.GetConnection(sFileName, host, db_version)	'16102 is the number from the SAI file for the element "data_version"

			End If

			If error2 <> Simply.ConnectionManagerService.ConnectionManagerError.No_Error Then

				Throw New Exception(error2.ToString)

			End If

		Catch ex As Exception

			'Notify user of error thrown by connection attempt

		End Try

	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click



			Dim f As New Library.MySqlDBAccess2.cMySqlDBAccess2

			Dim sConn As String = "Provider=MSDASQL;DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;Database=simply;" & _


			Dim ds As New DataSet

			If f.RunSQLReturnODBCDataSet(sConn, "SELECT * FROM temp;", ds) = False Then

				Throw f.LastException

			End If

		Catch ex As Exception

			'catch exceptions here.

		End Try

	End Sub

	Public Function RunSQLReturnODBCDataSet(ByVal connStr As String, ByVal strSQL As String, ByRef MyResults As DataSet) As Boolean

		Dim myCmd As Odbc.OdbcCommand = New Odbc.OdbcCommand(strSQL, New Odbc.OdbcConnection(connStr))

		Dim dsResult As DataSet

		Dim sqlDa As Odbc.OdbcDataAdapter = Nothing


			dsResult = New DataSet

			sqlDa = New Odbc.OdbcDataAdapter(myCmd)

			myCmd.CommandType = CommandType.Text



			MyResults = dsResult

			Return True

		Catch ex As Exception

			LastException = ex

			Return False



			myCmd.Connection = Nothing


			sqlDa = Nothing

			dsResult = Nothing

		End Try

	End Function

End Class

Open in new window


Author Comment

Comment Utility
Woops.  forgot to alter the code a little.  The function "RunSQLReturnODBCDataSet" was in a class that I use to
abstract away a lot of the details of connecting to datasources and forgot take out the "f" object variable.
I wanted to show the whole code for the sake of completeness.

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Creating and Managing Databases with phpMyAdmin in cPanel.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now