Get/Read Ship-To Address from Sage 50 Accouting for a specific Sales order

Is there a way (and I imagine there is) to read the Ship-To name and address information for a particular sales order from the peachtree database to an external application using the Sage 50 SDK?

I will basically be using an ODBC connection to the Peachtree database for this as I'm trying to get the Ship-To information from the Peachtree system into a custom application that we will be used for automatically filling out bill of lading documents using this info.

  • 0

    By the way, we are using Sage 50 Accounting 2015 edition, and I'm a bit new to the SDK/API programming, although I'm an experienced C# programmer.

  • 0 in reply to cbassett03

    This should get you started:

    '**** GET ORDER HEADER INFORMATION ********

           Dim connectionString As String = "DSN=" & gvAccountingDsn & ";UID=" & gvOdbcUser & ";PWD=" & gvOdbcPassword & ";"

           Dim conn As OdbcConnection

           Dim comm As OdbcCommand

           Dim rdr As OdbcDataReader

           Dim strSQL As String = ""

           Dim DQ As String = Chr(34)

           strSQL = "SELECT C.CustomerId, E.EmployeeId, J.TransactionDate, J.SalesTaxCode, "

           strSQL += "J.TermsDescription, J.ShipToName, J.ShipToAddress1, J.ShipToAddress2, "

           strSQL += "J.ShipToCity, J.ShipToState, J.ShipToZip, J.ShipToCountry, J.ShipVia, J.PrintCommentAtEnd, "

           strSQL += "J.Comment, J.Comment2, J.Comment3, J.ShipByDate, J.CustomerInvoiceNo, G.AccountID "

           strSQL += "FROM " & DQ & "JrnlHdr" & DQ & " J "

           strSQL += "LEFT OUTER JOIN " & DQ & "Customers" & DQ & " C ON J.CustVendId = C.CustomerRecordNumber "

           strSQL += "LEFT OUTER JOIN " & DQ & "Employee" & DQ & " E ON J.EmpRecordNumber = E.EmpRecordNumber  "

           strSQL += "LEFT OUTER JOIN " & DQ & "Chart" & DQ & " G ON J.GLAcntNumber = G.GLAcntNumber  "

           strSQL += "WHERE J.reference = '" & OrderId & "' AND "

           strSQL += "J.JrnlKey_Journal = 11 "

           conn = New OdbcConnection(connectionString)

           Try

               conn.Open()

           Catch ex As Exception

               conn.Close()

               conn.Dispose()

               MsgBox(ex.Message, MsgBoxStyle.Critical, "Failed to open connection to database.")

               Return False

           End Try

           comm = New OdbcCommand(strSQL, conn)

           rdr = comm.ExecuteReader()

           While rdr.Read()

               CustomerId = Trim(rdr.Item("CustomerId"))

               'balance of assignments removed

           End While

           rdr.Close()

           comm.Dispose()

    Scott