在ASP+中访问数据库

诺墁底的夕阳

诺墁底的夕阳

2016-01-29 13:57

在ASP+中访问数据库,在ASP+中访问数据库
In an ASP+ page ,databases can be accessed by employing ADO+ objects. In order to retrieve values from
databases through ADO+ we have to follow certain procedures which are different from those employed in ADO.

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com)

The article throws Light on Various steps involved in using ADO+ in an ASP page for retrieving the
database values for an access database.

The datagrid control provided with ASP+ is used for displaying the values retrieved from the database.

First include the language in which the asp+ page will be coded. This is specified by using Page directive
as shown below. In this example Let us use 'VB' as The language for coding ASP+ Page. The above thing can
be achieved by using the following page directive as shown below.

<%@ Page Language="VB"%


Next Import the namespaces required for creating the Datasetcommand object and Other ADO objects such as
connection , dataset. This can be done by the following asp+ statements

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


Next create the script required for accessing the database. In this example let us use a server side
submit control whose onClick triggers The script given below

<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

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com)


Finally place the following html in the asp+ code

<html
<body

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


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

</body
</html

Thats it! The datagrid control in ASP+ page is filled up with the values retrieved from the access
database (database.mdb)

Gopikrishna S
Gopikrishna is a specialist in ASP, MTS ,JavaScript , Vbscript, Windows DNA and VBCom . He is currently
associated with Silverline Technologies Limited Chennai.

展开更多 50%)
分享

猜你喜欢

在ASP+中访问数据库

电脑网络
在ASP+中访问数据库

在ASP程序中访问Access数据库

ASP
在ASP程序中访问Access数据库

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

ASP+联结数据库

电脑网络
ASP+联结数据库

在ASP中如何访问Novell下的数据库

ASP
在ASP中如何访问Novell下的数据库

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

ASP访问INTERBASE数据库

ASP
ASP访问INTERBASE数据库

在ASP中优化数据库处理

ASP
在ASP中优化数据库处理

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

《刀塔传奇》燃烧的远征英雄阵容搭配推荐

《刀塔传奇》燃烧的远征英雄阵容搭配推荐

《时空猎人》杨家枪法怎么样

《时空猎人》杨家枪法怎么样
下拉加载更多内容 ↓