- [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 ;
- }
- }
- }
-
- }
- //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>
I want to Load my data table content to array and return array to front end using page methods..Suggest me some ideas..