ASP+联结数据库,ASP+联结数据库
【 tulaoshi.com - ASP.NET 】
< %@ Import Namespace="System.Data" %<html
< script language="C#" runat="server"
'声明C#
public DataSet dsCustomer;
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)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
来源:http://www.tulaoshi.com/n/20160129/1492415.html