深圳升蓝软件
数据库开发 .Net技术  |  ASP技术 PHP技术 JSP技术 应用技术类   
Hiblue Software

ASP+联结数据库


March 25,2004
< %@ 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>
       
       
Copyright © 2001-2008 Shenzhen Hiblue Software Team All rights reserved