用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心.Net

一个用asp+存取数据库的例子

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-12 16:00:58
<%@ Page Language="VB"%>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>




<script language="VB" runat="server">
  Sub subbtn_OnClick(Sender As Object, E As EventArgs)
      Dim connobj As ADOConnection
      Dim dtsCmdobj As ADODataSetCommand
      Dim dtSobj As DataSet
      Dim str_sql As String
      dim conn_str As String
      str_sql = "select * from table_name"
      conn_str = "DBQ=" & Server.MapPath("database.mdb") &_
                 ";Driver={Microsoft Access Driver (*.mdb)};"

      connobj = New ADOConnection(conn_str)
      dtsCmdobj = New ADODataSetCommand(str_sql, connobj)
      dtSobj = New DataSet()
      dtsCmdob.FillDataSet(dtsobj, "table_name")
      dtgrid.DataSource = dtsobj.Tables("table_name").DefaultView
      dtgrid.DataBind()
End Sub
</script>




<html>
<body>

<form action="db.aspx" method="post" runat="server">
<asp:Button type="submit" id="subbtn" text="Run Query" runat="server" />
</form>


<asp:DataGrid id="dtgrid" HeaderStyle-Font-Bold="True" ToolTip="data Grid provided with asp+" runat="server" maintainviewstate="false" />

</body>
</html>

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论

栏目导航

本类热门阅览

相关文章

PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:10,031.25000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号