Call stored procedure using a button on Customer Maintenance

SOLVED

We're looking to build a function to push newly entered customer data (for new account setups) out to an external database for one of our in-house programs (both Sage and external are on SQL 2016). What our developer is suggesting is using a stored procedure passing all the fields as parameters, we can then do validation, update vs. add new, etc. so we could have this integration happen live.

Before I give the ok on this I wanted to confirm that Sage allows for calling a stored procedure off of a custom button in the Customer Maintenance panel.

Parents Reply
  • 0 in reply to FormerMember

    Are you talking about through something like this?

    Set dbConn = CreateObject("ADODB.Connection")

    I guess this would work, but we only use that method for a query / record set now.  The reason we use SQLCMD is to capture any results / error messages in a log file (-o), and it doesn't tend to lock-up the way VBScript working with SQL data tends to do on occasion.

Children
  • FormerMember
    0 FormerMember in reply to Kevin M

    I'm using ScriptBasic's ODBC extension module. I'm not a big fan of ADO as it's bloatware with everything being an object.

  • 0 in reply to FormerMember

    It works for simple things and doesn't require any additional software being installed for it to work, but I agree ADO is not ideal for complex use.

  • 0 in reply to Kevin M
    The reason we use SQLCMD is to capture any results / error messages in a log file (-o), and it doesn't tend to lock-up the way VBScript working with SQL data tends to do on occasion.

    Could you expand upon that more? I'm currently drafting up a script and want to work the SQLCMD route

  • FormerMember
    0 FormerMember in reply to Yung_Grasshopper

    I tried using the Accept button event in one of my scripts. It caused a Windows exception error. I ended up using the after write event which worked as expected.

  • FormerMember
    0 FormerMember in reply to Kevin M

    Keep in mind that using VBScript and ADO inside a hosted COM component has limitations.

    A good example is the SQLite wrapped ActiveX control I tried using with WSH It dies with a message saying unable to load with no error or reason. The control works with ScriptBasic and everything else I tried it with.

  • 0 in reply to Yung_Grasshopper

    These are batch file commands... used in processes initiated outside of Sage 100 (not scripts) so you're on your own for that part of it.

    This captures the SQL return messages (like "2 rows affected", or a connection error) into a temp log file, which I copy into a daily log file, for potential reference when troubleshooting.

    SET TodayLogFile=E:\Accounting\logs\Refresh_%date:~-4,4%%date:~-10,2%%date:~-7,2%.txt
    SET TempLogFile=E:\Accounting\logs\Refresh.txt
    
    ECHO %date% %time% Starting Refresh >> %TodayLogFile%
    sqlcmd -S Server\Instance -E -d MAS_ABC -Q "update ... blah blah blah;" -o %TempLogFile%
    type %TempLogFile% >> %TodayLogFile%
    ECHO %date% %time% Finishing Refresh >> %TodayLogFile%