Home » Posts tagged "select"

Archive for the 'select' Tag

VB.NET – SQL statement “LIKE”

Input box Please enter customer first or last name: <asp:RequiredFieldValidator ID=”ReqSearchfor” runat=”server” ErrorMessage=”<font color=’red’>Input box can not be empty!</font>” ControlToValidate=”SearchFor” > <asp:TextBox ID=”SearchFor” runat=”server”> <asp:Button ID=”SearchBtn” runat=”server” Text=”Search” /> SQL DataSource Design <asp:SqlDataSource ID=”SearchResults” runat=”server” ConnectionString=”< %$ myConString %>” SelectCommand=”SELECT * FROM [CustomerTbl] WHERE ([customer_name] LIKE ‘%’ + @customer_name + ‘%’)” <SelectParameters> <asp:ControlParameter ControlID=”SearchFor” Name=”customer_name” […]

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 […]