Click or drag to resize

MPInterfaceReadDataFromDB Method

Function to read data from MARIProject database. You can use any SELECT statement to fill a datatable. Only SELECT satements are allowed

Namespace:  MARIInterface
Assembly:  MARIInterface (in MARIInterface.dll) Version: 8.0.0.100
Syntax
public DataTable ReadDataFromDB(
	string sSQL
)

Parameters

sSQL
Type: SystemString
Also for HANA use MS-SQL syntax. For SBO Fields use [CardCode], becuase the fields are case sensitive in HANA. For MARIProject Fields use Fields without brackets (All fields in HANA are in capital letters.) For the english views in MARIProject use [Brackets] again. They are case sensitive in HANA.

Return Value

Type: DataTable
Remarks
Examples
Simple Example for SQL Data
private int lReadPurchaseProcessIDByNumber(string sPurchaseProcessNumber) {
    string sParam = sPurchaseProcessNumber.Replace("\'", "\'\'"); //replace any ' in the parameter with ''
    string sSQL = "SELECT [ContractID] FROM [MARIPurchaseProcess] WHERE [POProcessNo]=N'" + sParam + "'";
    // MARIProject will translate this MS-SQL style string to the HANA Syntax
    // SELECT "ContractID" FROM "MARIPurchaseProcess" WHERE "POProcessNo"=N'31123123123'

    //Use ReadDataFromDB to quickly read a value
    System.Data.DataTable oTable = oMPInterface.ReadDataFromDB(sSQL);
    if (oTable.Rows != null || oTable.Rows.Count > 0) {
        return Convert.ToInt32(oTable.Rows[0]["ContractID"]);
    }
    return 0;
}

private int lReadDocNumFromInvoice(int lDocEntry) {
    const string SBO_DB_NAME = "SBODEMOUS";

    //the access to the SBO database is done indirectly via the MARIProject database connection.
    // use [] and case sensitive columns to be compatible with HANA databases.
    string sSQL = $"SELECT [DocNum] FROM {SBO_DB_NAME}.dbo.OINV WHERE [DocEntry]={lDocEntry}";
    // MARIProject will translate this MS-SQL style string to the HANA Syntax
    // SELECT "DocNum" FROM SBODEMOUS.OINV WHERE "DocEntry"=123

    //Use ReadDataFromDB to quickly read a value
    System.Data.DataTable oTable = oMPInterface.ReadDataFromDB(sSQL);
    if (oTable.Rows != null || oTable.Rows.Count > 0) {
        return Convert.ToInt32(oTable.Rows[0]["DocNum"]);
    }
    return 0;
}
See Also