js处理DataSet数据源

  1. [Ajax.AjaxMethod()]   
  2.        public DataSet GetDataSet()   
  3.        {   
  4.            OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:工作项目分析 estdb.mdb;Persist Security Info=True;");   
  5.            DataSet ds = new DataSet();   
  6.            try  
  7.            {   
  8.                OleDbCommand cmd = conn.CreateCommand();   
  9.                cmd.CommandText = "select * from t_name";   
  10.                cmd.CommandType = CommandType.Text;   
  11.   
  12.                OleDbDataAdapter da = new OleDbDataAdapter(cmd);   
  13.                da.Fill(ds);   
  14.                return ds;   
  15.            }   
  16.            catch  
  17.            {   
  18.                conn.Close();   
  19.                throw;   
  20.            }   
  21.        }  


 

  1. <script language="JavaScript">   
  2.   
  3. // var ds =test.GetDataTable().value;  //table数据源   
//alert(ds.Rows[i].level2;                              function  getDataSet()                {                     var  ds =test.GetDataSet().value;                     if (ds !=  null  &&  typeof (ds) ==  "object"  && ds.Tables !=  null )                    {                         var  s =  new  Array();                        s[s.length] =  "<table style='border: #000000 1px solid; color: #993333; font-family: 'Microsoft Sans Serif'; background-color: #ffff99;'>" ;                            for ( var  i=0; i<ds.Tables[0].Rows.length; i++)                        {                            s[s.length] =  "<tr>" ;                            s[s.length] =  "<td>"  + ds.Tables[0].Rows[i].id +  "</td>" ;                            s[s.length] =  "<td>"  + ds.Tables[0].Rows[i].f_date +  "</td>" ;                            s[s.length] =  "<td>"  + ds.Tables[0].Rows[i].f_name +  "</td>" ;                            s[s.length] =  "</tr>" ;                        }                           s[s.length] =  "</table>" ;                        document.getElementById( "div1" ).innerHTML = s.join( "" );                        }                     else                    {                        alert( "调用Ajax接口函数错误!" );                    }                }            </script>  

转载于:https://www.cnblogs.com/leesa/archive/2010/03/29/1699367.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值