Mega Code Archive

 
Categories / ASP.Net / Components
 

Tip of the Day Demo (VB net)

<%-- Code revised from  ASP.NET Tips & Techniques (Paperback) by Greg Buczek  # Publisher: McGraw-Hill/Osborne Media; 1st edition (May 21, 2002) # Language: English # ISBN: 0072225149 --%>                          <%@ 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)     Dim DBConn as OleDbConnection     Dim DBCommand As OleDbDataAdapter     Dim DSPageData as New DataSet     If Application("TipDate") <> Today() Then         Application("TipDate") = Today()         If Not Isnumeric(Application("TipNumber")) Then             Application("TipNumber") = 1         Else             Application("TipNumber") = _                 Application("TipNumber") + 1         End If     End If     DBConn = New OleDbConnection( _         "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _         & "DATA SOURCE=" _         & Server.MapPath _         ("TipDB.mdb;"))     DBCommand = New OleDbDataAdapter _         ("Select TipTitle, TipText From Tips " _         & "Where SequenceNumber = " _         & Application("TipNumber"), DBConn)     DBCommand.Fill(DSPageData, _         "TheTip")     If DSPageData.Tables("TheTip").Rows.Count = 0 Then         Application("TipNumber") = 1         DBCommand = New OleDbDataAdapter _             ("Select TipTitle, TipText From Tips " _             & "Where SequenceNumber = " _             & Application("TipNumber"), DBConn)         DBCommand.Fill(DSPageData, _             "TheTip")     End If     lblTipTitle.Text = _         DSPageData.Tables("TheTip").Rows(0). _         Item("TipTitle")     lblTipText.Text = _         DSPageData.Tables("TheTip").Rows(0). _         Item("TipText") End Sub </SCRIPT> <HTML> <HEAD> <TITLE>Tip of the Day</TITLE> </HEAD> <Body LEFTMARGIN="40"> <form runat="server"> <BR><BR> <asp:label      id="lblTitle"      font-size="12pt"     font-bold="True"     font-name="Lucida Console"     runat="server"     text="Current Tip of the Day" /> <BR><BR> <asp:label      id="lblTipTitle"      font-size="10pt"     font-name="Lucida Console"     runat="server" /> <BR> <asp:label      id="lblTipText"      font-size="10pt"     font-name="Lucida Console"     runat="server" /> </form> </BODY> </HTML>                     TipDB.zip( 8 k)