Home » 2011 » August

Archive for August, 2011

Select Count * (count total of records)

VB.NET Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Try ‘/ access db connection – MS Access 2007/10 ‘ driver * you can define your own sql connection Dim ConnDB As New OleDbConnection(“Provider=Microsoft.ACE.OLEDB.12.0; Data Source=” & Server.MapPath(“my_db.accdb”)) ‘/ open connection ConnDB.Open() Dim cmd As New OleDbCommand(“select count(*) from table1 […]

VB.NET date and time format

Date as Monday, August 29, 2011 Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Dim dd As Date = Date.Today label1.Text = String.Format(“{0:dddd, MMMM d, yyyy}”, dd) End Sub Other formats… ‘ – month/day numbers without/with leading zeroes String.Format(“{0:M/d/yyyy}”, dt); ‘ “8/29/2011” String.Format(“{0:MM/dd/yyyy}”, dt); ‘ “08/29/2011” ‘ – day/month names String.Format(“{0:ddd, MMM d, […]

ASP.NET Validation Controls

RequiredFieldValidator asp:TextBox Id=”UserName” runat=”server” /> /asp:TextBox>* asp:RequiredFieldValidator id=”valUserNameRequired” ControlToValidate=”UserName” ValidationGroup=”Form1″ ErrorMessage=”UserName is a required field.” Display=”None” Runat=”server”> CompareValidator [password] asp:TextBox Id=”UserName” runat=”server” /> /asp:TextBox>* asp:CompareValidator id=”valComparePassword” ControlToValidate=”ConfirmPassword” ValidationGroup=”Form1″ ErrorMessage=”Password fields must match.” ControlToCompare=”txtPassword” Display=”None” EnableClientScript=”true” Runat=”server”/> CompareValidator [date] asp:TextBox Id=”date” runat=”server” /> /asp:TextBox>* asp:CompareValidator id=”valDate” Type=”Date” ControlToValidate=”Date” Operator=”DataTypeCheck” ValidationGroup=”Form1″ ErrorMessage=”mm/dd/yyyy” Display=”None” Runat=”server”/> RegularExpressionValidator [email] asp:TextBox […]