R 3.4.2
WebAPI Method calling R Script: <pre>Public HttpResponseMessage CallTestMethod() { // SetupPath(); setting Rpackage and ODBC package paths in environment no issue with this method. REngine engine; engine = REngine.GetInstance(); //Mentioned R Script file path var val = engine.Evaluate("source('C:/Folder/RProject1/Script.R')"); //Call FetchDatawithoutParam () and get data frame values in dsResult . var dsResult = engine.Evaluate(@"TempDataResult <- FetchDatawithoutParam ()").AsDataFrame(); }
FetchDatawithoutParam <- function() { dbConnection <- odbcDriverConnect('driver={SQL Server};server=.;database=DBName;trusted_connection=true') DataResult <- sqlQuery(dbConnection, "SELECT * FROM TableName;") odbcClose(dbConnection) return(DataResult ); }
odbcClose(dbConnection)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)