public class DbaseQuery
{
public dynamic GetSQLResult(dynamic clientParam)
{
string conSTR = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + AppDomain.CurrentDomain.BaseDirectory + @"App_Data\Database1.mdf;Integrated Security=True";//SQL database connection string
string xquery = "SELECT * FROM table1";
SqlConnection sqlConn = new SqlConnection(conSTR);
sqlConn.Open();
SqlCommand cmd = new SqlCommand(xquery, sqlConn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
for (var i = 0; i < dt.Rows.Count; i++)
{
for (var j = 0; j < dt.Rows[i].ItemArray.Length; j++)
{
dt.Rows[i].ItemArray[j] = dt.Rows[i].ItemArray[j].ToString().Trim();
}
}//datasource
return dt;
}} |
public Dictionary<string, object> InitializeGrid(Dictionary<string, object> jsonResult)
{
htmlHelper.PivotReport = BindDefaultData();
dict = htmlHelper.GetJsonData(jsonResult["action"].ToString(), dbquery.GetSQLResult(null));
return dict;
} |