{
DataTable dt = new DataTable();
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
using (SqlCommand cmd = new SqlCommand("Select * from TM_Product_Details", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List
Dictionary
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
//Context.Response.Write(js.Serialize(rows));
this.Context.Response.ContentType = "application/json; charset=utf-8";
this.Context.Response.Write(serializer.Serialize(new { All_Product_Data = rows }));
}
else
{
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
this.Context.Response.ContentType = "application/json; charset=utf-8";
this.Context.Response.Write(serializer.Serialize("No Record Found !!!"));
}
}
}
Abhishek SrivastavaPosted Mar 23, 2017, 8:09 AM
Jitendra ShekhawatPosted Mar 23, 2017, 5:31 AM
Jitendra ShekhawatPosted Mar 23, 2017, 5:30 AM