[Ajax.AjaxMethod()] public DataSet AjaxGetDataSet() { dbconn = new OleDbConnection(); String strPath = Server.MapPath(@"App_Data/UserInfo.mdb"); strPath = strPath.Replace("ajax//", ""); dbconn.ConnectionString = @"provider=Microsoft.Jet.OleDb.4.0;Data Source=" + strPath; cmd = new OleDbCommand("select * from users", dbconn); OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet(); try { dbconn.Open(); try { da.Fill(ds); // fill DataSet with data } catch(Exception) { return null; } finally { dbconn.Close(); dbconn.Dispose(); } } catch(Exception) { return null; } return ds; }
function AddItemToDropDownList() { var jdataSet = _default.AjaxGetDataSet(callback_x) } function callback_x(res) { if (null != res && null != res.value.Tables[0]) { if (null != res.value.Tables[0].Rows) { alert(res.value.Tables[0].Rows.length); } } else { alert('null '); } }