How to use CSQRY using .NetAPI in C#

By | July 29, 2019

CSQRY

CSQRY is the View CS0120. It basically takes SQL Query as the parameter to its Browse method and then returns the records via calls to Fetch. CSQRY is easy to execute general SQL statements through the Sage 300 API. This way we don’t need additional database credentials and don’t need to use an alternate API like ODBC.

New Stuff:  How to open OE Order Entry View using Advantage API

Step 1:

Include the Sage 300 Advantage DLL in the project.

Step 2:

Once the Advantage DLL is included, create the object of the DBLink and open the “CS0120” using DBLink object.

DBLink dBLink = session.OpenDBLink(DBLinkType.Company, DBLinkFlags.ReadWrite);

View view = dBLink.OpenView(“CS0120”);

Step 3:

Pass the SQL Query in Browse method as string parameter.

view.Cancel();

view.Browse(“SELECT OPTFIELD FROM CSOPTFH (NOLOCK) WHERE TYPE = ‘1’”, true);

view.InternalSet(256);

Step 4:

Now we call the Fetch method to return the records.

List<string>  optionalFieldList = new List<string>;

while (view.Fetch() == true)

{

                    for (int i = 0; i < _ view.Fields.Count; i++)

                    {

                        optionalFieldList.Add(view.Fields.FieldByIndex[i].Value);

     }

}

About Us:-

Greytrix a globally recognized Premier Sage Gold Development Partner is a one stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.

Greytrix offers unique GUMU™ integrated solutions of Sage 300 with Sage CRM, Salesforce.com and Magento eCommerce along with Sage 300 Migration from Sage 50 US, Sage 50 CA, Sage PRO, QuickBooks, Sage Business Vision and Sage Business Works. We also offer best-in-class Sage 300 customization and development services and integration service for applications such as POS | WMS | Payroll | Shipping System | Business Intelligence | eCommerce for Sage 300 ERP and in Sage 300c development services we offer services such as upgrades of older codes and screens to new web screens, newer integrations using sdata and web services  to Sage business partners, end users and Sage PSG worldwide. Greytrix offers over 20+ Sage 300 productivity enhancing utilities that we can help you with such as GreyMatrix, Document Attachment, Document Numbering, Auto-Bank Reconciliation, Purchase Approval System, Three way PO matching, Bill of Lading and VAT for Middle East.

For more details on Sage 300 and 300c Services, please contact us at accpac@greytrix.com. We will be glad to assist you.