您现在的位置:首页 >> 数据库 >> 技术支持 >> 信息正文

在ASP.NET中,如何数据库的连接调用?

2009-10-26 21:08:23 来源: 南天互联 作者:站长 录入:admin 访问:9161 次 被顶:1 次 字号:【
核心提示:以下是我们用C#来实现的,见下列实例代码,请万网独立服务器客户参考: %@ Import Namespace='System.Data' %%@ Import Namespace='System.Data.SQL' % html scrip...

以下是我们用C#来实现的,见下列实例代码,请万网独立服务器客户参考:

< %@ 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=127.0.0.1;uid=xxx;pwd=*****;database=***_db");

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>

参与评论
共有评论 0网友评论列表
© CopyRight 2009 南天互联帮助中心, Inc.All Rights Reserved.
Powered by:南天互联 Design by:Nicnt 鲁ICP备08105365号