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

Hi folks,

I am having a problem trying to connect to simply accounting enterprise 2009 (SAE2K9) through vb.net 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.
LVL 1
sharizodAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sharizodAuthor Commented:
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.

Cheers
Imports MySql.Data
Imports MySql.Data.MySqlClient
 
Public Class Form1
 
	Public Sub ConnectTo2Simply()
 
		Try
 
			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
 
		ConnectTo2Simply()
 
		Try
 
			Dim f As New Library.MySqlDBAccess2.cMySqlDBAccess2
 
			Dim sConn As String = "Provider=MSDASQL;DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;Database=simply;" & _
			"UID=sysadmin;PWD=;Port=13540;Socket=SimplyMySql13540;option=3"
 
			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
 
		Try
			dsResult = New DataSet
			sqlDa = New Odbc.OdbcDataAdapter(myCmd)
 
			myCmd.CommandType = CommandType.Text
			myCmd.Connection.Open()
			sqlDa.Fill(dsResult)
 
			MyResults = dsResult
			Return True
 
		Catch ex As Exception
			LastException = ex
			Return False
 
		Finally
			myCmd.Connection.Close()
			myCmd.Connection = Nothing
			sqlDa.Dispose()
			sqlDa = Nothing
			dsResult = Nothing
 
		End Try
 
	End Function
 
End Class

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sharizodAuthor Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Tax / Financial Software

From novice to tech pro — start learning today.