ASP.Net/Components/What is new — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:51, 26 мая 2010
What is new form (VB.net)
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
If Not IsPostBack Then
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection( _
"PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath _
("WhatsNewDB.mdb;"))
DBCommand = New OleDbDataAdapter _
("Select Top 1 TheNews From News " _
& "Order By DateEntered Desc", DBConn)
DBCommand.Fill(DSPageData, _
"News")
lblTheNews.Text = _
DSPageData.Tables("News").Rows(0). _
Item("TheNews")
DBCommand = New OleDbDataAdapter _
("Select NewsID, DateEntered From News " _
& "Order By DateEntered DESC", DBConn)
DBCommand.Fill(DSPageData, _
"NewsDates")
ddlNews.DataSource = _
DSPageData.Tables("NewsDates").DefaultView
ddlNews.DataBind()
End If
End Sub
Sub ddlNews_Changed(Sender As Object, E As EventArgs)
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection( _
"PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath _
("WhatsNewDB.mdb;"))
DBCommand = New OleDbDataAdapter _
("Select TheNews From News " _
& "Where NewsID = " & ddlNews.SelectedItem.Value _
, DBConn)
DBCommand.Fill(DSPageData, _
"News")
lblTheNews.Text = _
DSPageData.Tables("News").Rows(0). _
Item("TheNews")
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>What"s New</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<BR><BR>
<asp:label
id="lblTheNews"
font-size="12pt"
font-bold="True"
font-name="Lucida Console"
runat="server"
/>
<BR><BR>
<asp:label
id="lblMessage2"
font-size="10pt"
font-name="Lucida Console"
text="View old News"
runat="server"
/>
<BR>
<asp:dropdownlist
id="ddlNews"
datatextfield="DateEntered"
datavaluefield="NewsID"
autopostback="True"
onselectedindexchanged="ddlNews_Changed"
runat="server"
/>
</form>
</BODY>
</HTML>
<A href="http://www.nfex.ru/Code/ASPDownload/WhatsNewDB.zip">WhatsNewDB.zip( 8 k)</a>