手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >js DataSet数据源处理代码
js DataSet数据源处理代码
摘要:[Ajax.AjaxMethod()]publicDataSetGetDataSet(){OleDbConnectionconn=newOl...

[Ajax.AjaxMethod()]

public DataSet GetDataSet()

{

OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:工作项目分析 estdb.mdb;Persist Security Info=True;");

DataSet ds = new DataSet();

try

{

OleDbCommand cmd = conn.CreateCommand();

cmd.CommandText = "select * from t_name";

cmd.CommandType = CommandType.Text;

OleDbDataAdapter da = new OleDbDataAdapter(cmd);

da.Fill(ds);

return ds;

}

catch

{

conn.Close();

throw;

}

}

[/code]

复制代码 代码如下:

<script language="JavaScript">

// 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] = "<tableMicrosoft 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>

【js DataSet数据源处理代码】相关文章:

AngularJS数据源的多种获取方式汇总

JavaScript基本数据结构

实现DIV圆角的JavaScript代码

Ctrl + Enter提交前检测的代码

鼠标图片振动代码

Javascript随机显示图片的源代码

JavaScript数据结构与算法之链表

使用Node.js处理前端代码文件的编码问题

js中跨域方法原理详解

js+html5操作sqlite数据库的方法

精品推荐
分类导航