当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > ASP+联结数据库

ASP.NET
ASP.NET 2.0服务器控件开发的基本概念
教你如何实现ASP.NET中网站访问量的统计
.Net基础:ASP.NET网站开发的架构设计
ASP.NET应用技巧:非托管COM组件的使用
.Net基础:ASP.NET中的session存储模式运用
.Net的精髓——XML和SOAP
.NET 4.0改进的介绍
使用.NET正则表达式区分中英文
ASP.NET开发中关于Web标准的几点建议
ASP.NET开发安全问题
谈.NET反射的封装
ASP.NET用户控件说明和添加事件
C#编程实现动态生成Word文档
Asp.net2.0之自定义控件ImageButton
.net程序员,该不该学IL?
利用ajax.dll进行asp.net ajax开发
软件编程走火入魔之:女人的脸 男人的代码
分页那回事?
ASP.NET WebForm页面内容输出方式
浅析ASP.NET的IIS映射

ASP.NET 中的 ASP+联结数据库


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 73 ::
收藏到网摘: n/a

< %@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>

<html>

< script language="C#" runat="server">
'声明C#

public DataSet dsCustomer;

protected void Page_Load(Object Src, EventArgs E )

{
'当打开页面时联结数据库

SQLConnection myConnection = new SQLConnection
("server=sql2.bitsonthewire.com;uid=joeuser;pwd=joeuser;database=northwind");

SQLDataSetCommand CustomersDSCommand = new SQLDataSetCommand("select * from customers", myConnection);
dsCustomer = new DataSet();


CustomersDSCommand.FillDataSet(dsCustomer,"Customers");

foreach (DataRow Customer in dsCustomer.Tables["Customers"].Rows)

{

Response.Write(Customer["CustomerId"].ToString() + "<br> " ); } }

</script>

<body>

</body>
</html>


</td>
</tr>
</table>
</body>