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

ASP.NET
AspNetPager与Socut.Data使用方法
asp.net UpdaeProgress的简单用法
asp.net ajaxControlToolkit ValidatorCalloutExtender的简单用法
asp.net 简易生成注册码(数字+大小写字母)
asp.net中利用ashx实现图片防盗链代码
ASP.NET程序中常用代码汇总
ASP.NET 2.0/3.5中直接操作Gridview控件插入新记录
ASP.NET Ajax级联DropDownList实现代码
ASP.NET 2.0写无限级下拉菜单
asp.net Web Services上传和下载文件(完整代码)
asp.net DataGrid控件中弹出详细信息窗口
Asp.NET 多层登陆实现代码
利用Asp.Net回调机制实现进度条
ASP.NET Ref和Out关键字区别分析
Javascript调用Webservice的多种方法
.Net下的签名与混淆图文分析
.Net Compact Framework开发小技巧 推荐
.Net连接Oracle数据库的实现代码
js获取.aspx页面里面的服务器控件和.ascx中的服务器控件值
asp.net下 jquery jason 高效传输数据

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 42 ::
收藏到网摘: 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>