明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

ASP+聯(lián)結(jié)數(shù)據(jù)庫

[摘要]< %@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SQL...
< %@ 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 )

{
'當(dāng)打開頁面時(shí)聯(lián)結(jié)數(shù)據(jù)庫

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>