Using CS0120 to connect to read and write to a non-Sage 300 SQL database (Sage CRM)

I have this working with the Sage 300 company database but need to read from another SQL database.

Does anyone have some sample  code to get me started?

Any and All advice greatly appreciated,

Dana

Parents Reply Children
  • 0 in reply to Jay Converse Acumen

    This is part of my code.  It's not working

    What have I missed?

    Dim SQLStr As String
    Dim csTemp As AccpacCOMAPI.AccpacView

    Set mComLink = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

    mComLink.OpenView "CS0120", csTemp


        SQLStr = "SELECT Comp_IdCust, Comp_Name, Comp_Status FROM CRM.Company WHERE Comp_Status = Active ORDER BY Comp_IdCust"

    csTemp.Browse SQLStr, True       '<<< Fails on this line - Method 'Browse' of object 'IAccpavView' failed
    csTemp.InternalSet (256)

  • 0 in reply to Dana B. Stidsen

    A period between CRM and Company.  You can use two periods instead of .dbo.

    SELECT Comp_IdCust, Comp_Name, Comp_Status FROM CRM..Company WHERE Comp_Status = Active ORDER BY Comp_IdCust