- [System.Web.Services.WebMethod]
- public Array loaddata()
- string sql = "SELECT Name,Time,Inuse FROM table4";
- using (SqlConnection Connection = new SqlConnection((@"Data Source)))
- {
- using (SqlCommand myCommand = new SqlCommand(sql, Connection))
- {
- Connection.Open();
- using (SqlDataReader myReader = myCommand.ExecuteReader())
- {
- DataTable dt = new DataTable();
- dt.Load(myReader);
- Connection.Close();
- DataView dv = new DataView(dt);
- dv.RowFilter = (("Name='ACVX'"));
- var tableEnumerable = dv.ToTable().AsEnumerable();
- var tableArray = tableEnumerable.ToArray();
- return tableArray ;
- }
- }
- }
- }
Load data table to array and return array using Jquery
- //Front End
- <html>
- <head/>
- <script>
- PageMethods.loaddata(LoadSucc, LoadFail);
- function LoadSucc(obj) //obj is array returned from back end{obj-tablearray]
- {
- var goog = [];
- goog = Object.values(obj);
- //I want load the obj into my array goog.
- }
- function LoadFail() {
- alert("Data missing");
- }
- script>
- <body/>
- html>

Chetan RanpariyaRank #1,852 · 801 reputationPosted Dec 28, 2016, 1:33 AM EST
A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'.
My recommendation would be to create a custom class with properties Name, Time and InUse to store the data which you want to return to UI. Create object of that classe and populate the properties of that object from the data rows and create array of those objects and return them as JSON object from the server to the UI.sudipta sanyalRank #1,945 · 753 reputationPosted Dec 28, 2016, 1:46 AM EST
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Dec 28, 2016, 2:13 AM EST
sudipta sanyal
sudipta sanyalRank #1,945 · 753 reputationPosted Dec 28, 2016, 2:21 AM EST
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Dec 28, 2016, 2:24 AM EST
sudipta sanyalRank #1,945 · 753 reputationPosted Dec 28, 2016, 2:26 AM EST
Midhun TpRank #388 · 6.5K reputationPosted Dec 28, 2016, 7:05 PM EST