一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp.net数据连接代码

时间:2008-08-21 编辑:简简单单 来源:一聚教程网

asp.net数据连接代码,很简单的哦,如何用学了C#

< %@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
< 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() + "
" ); } }

热门栏目