2008-07-11

VB: Regular Expressions, etc...

Regex.IsMatch("subject", "regex") ' Checks if the regular expression 
' matches the subject string.

VB: using Controls collection

' Clears textbox controls' content on the form using 
' Controls collection.
Dim intX As Integer
Do While intX < text = "" intx =" intX">

ViewState("UrlReferrer")

Sub Page_Load()
    If Page.IsPostBack = False Then
        ' Store URL Referrer to return to home page.
        ViewState("UrlReferrer") = Me.Request.UrlReferrer.ToString()
    End If
End Sub

Sub CancelBtn_Click()
    ' Redirect back to the home page.
    Me.Response.Redirect(CType(ViewState("UrlReferrer"), String))
End Sub

ASP confirm

 gt-a-s-p:button id="ConfirmOnClick" runat="server" onclientclick="return
confirm('You\'re sure you want to do this?');" text="Launch Airstrike"> lt/ a-s-p:button> 

ASP .NET set focus to a control (javascript)

body onload="javascript:document.forms[0].txtFirst.focus();"

2008-07-10

check for DbNull

Check for DbNull:
<_a s p :Label runat="server" ID="Label6" Text='< % # IIF(Typeof(
Eval("ShippedDate")) IS DbNull,"No Date",Eval("ShippedDate")) % >' />
or
<_%# ((Convert.IsDBNull ... I am telling ASP to give the picture a height value only if the value in the database is not NULL. I could've done this in the SQL instruction, but I decided to do it inside the Datalist.
<_%# ((Convert.IsDBNull(DataBinder.Eval(Container.DataI tem, "height"))) ? "" : "height = " + DataBinder.Eval(Container.DataItem, "height")) %> 
Or maybe this for NULLs?: <_%# Eval("First", "{0}, ") %_>
Or check for NULL in T-SQL:
ISNULL(check_expression, replacement_value) If 1st is NULL, return 2cnd.

2008-07-03

Search Stored Procedures

This searches all the Stored Procedures in 1 SQL Server database for the said string. I tested it in Query Analyzer and it found all the Stored Procedures that had occurrences of my "lq_Campaign" in 1 database:
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%lq_Campaign%'
AND ROUTINE_TYPE='PROCEDURE'

Here is another way

Below query you can searcg any table, stored procedure or views what ever has that expression as a column or object name.

SELECT * FROM SYSOBJECTS WHERE ID IN (SELECT ID FROM SYSCOMMENTS WHERE TEXT LIKE ‘%PRODUC%’)

The query produced all the object names--where ever it finds expression like ‘PRODUC‘.

Model View Controller

  • Primary goal is to separate the things that change from the things that do not.
  • Model is the data representation.
  • View is the presentation of the model.
  • Controller responds to events and modifies the model.
  • Model notifies the views to update the presentation.