Archive for February, 2010

Query to find the list of Triggers in the database categorized with Trigger Type

SELECT S2.[name] TableName, S1.[name] TriggerName,
CASE
WHEN S1.deltrig > 0 THEN ‘Delete’
WHEN S1.instrig > 0 THEN ‘Insert’
WHEN S1.updtrig > 0 THEN ‘Update’
END ‘TriggerType’
FROM sysobjects S1 JOIN sysobjects S2
ON S1.parent_obj = S2.[id]
WHERE S1.xtype=’TR’

Following code can be used to validate a credit card number and to get the card brand
by card number:

///
/// Enum for card type.
///
public enum CardType
{
MasterCard = 1,
BankCard = 2,
Visa = 3,
AmericanExpress = 4,
Discover = 5,
DinersClub = 6,
JCB = 7,
unKnown = 8
}

///
/// It Will ensure that the card is a valid length for the card type. If the
/// card type isn’t recognised it will return false by default.
///
/// The ValidateCreditCard method also includes a CardTypes property that determines
/// what card types should be accepted. If the card isn’t recognised, and the Unknown card
/// type is in the AcceptedCardTypes property then the DefaultLengthTest value will be
/// returned.
///
public bool ValidateCreditCard(string cardNumber)
{
try
{// AMEX — 34 or 37 — 15 length
if ((Regex.IsMatch(cardNumber, “^(34|37)”)) && cardNumber.Length == 15)
{
CardBrand = CardType.AmericanExpress;
return true;
}
// MasterCard — 51 through 55 — 16 length
else if ((Regex.IsMatch(cardNumber, “^(51|52|53|54|55)”)) && 16 == cardNumber.Length)
{
CardBrand = CardType.MasterCard;
return true;
} // VISA — 4 — 13 and 16 length
else if ((Regex.IsMatch(cardNumber, “^(4)”)) && (13 == cardNumber.Length || 16 == cardNumber.Length))
{
CardBrand = CardType.Visa;
return true;
}
// Diners Club — 300-305, 36 or 38 — 14 length
else if ((Regex.IsMatch(cardNumber, “^(300|301|302|303|304|305|36|38)”)) && 14 == cardNumber.Length)
{
CardBrand = CardType.DinersClub;
return true;
}

// // enRoute — 2014,2149 — 15 length
// else if ((Regex.IsMatch(cardNumber, “^(2014|2149)”)) && 15 == cardNumber.Length)
// {
// CardBrand = CardType = “enROUTE”;
// return true;
// }
// Discover — 6011 — 16 length
else if ((Regex.IsMatch(cardNumber, “^(6011)”)) && 16 == cardNumber.Length)
{
CardBrand = CardType.Discover;
return true;
}
// JCB — 3 — 16 length
else if ((Regex.IsMatch(cardNumber, “^(3)”)) && 16 == cardNumber.Length)
{
CardBrand = CardType.JCB;
return true;

} // JCB — 2131, 1800 — 15 length
else if ((Regex.IsMatch(cardNumber, “^(2131|1800)”)) && 15 == cardNumber.Length)
{
CardBrand = CardType.JCB;
return true;
}
else
{
CardBrand = CardType.unKnown;
return false; //unknown card
}
}
catch (Exception ex)
{
throw ex;
}
}

_________________________________________________

Validating CARD VERIFICATION VALUE CODE

public bool ValidateCVVCode()
{
try
{
var digits = 0;
switch (CardBrand)
{
case CardType.MasterCard:
case CardType.BankCard:
case CardType.Visa:
case CardType.Discover:
case CardType.DinersClub:
case CardType.JCB:
digits = 3;
break;
case CardType.AmericanExpress:
digits = 4;
break;
default:
break;
}

Regex regEx = new Regex(“[0-9]{” + digits + “}”);
return (this.CVV == digits.ToString() && regEx.Match(this.CVV).Success);
}
catch (Exception ex)
{
throw ex;
}
}

Sql Caching in asp.net

Posted: February 8, 2010 in asp.net

VS command prompt

>aspnet_regsql -S streamline -U gamepoint1979 -P gamepoint1979 ed -d gamepoint2

>aspnet_regsql -S streamline -U gamepoint1979 -P gamepoint1979 -d gamepoint2 -et -t Teams

>aspnet_regsql -S streamline -U gamepoint1979 -P gamepoint1979 -d gamepoint2 -et -t MatchSetups

>aspnet_regsql -S streamline -U gamepoint1979 -P gamepoint1979 -d gamepoint2 -et -t MatchResults

WebConfig

Change the name of database from Gamepoint2 to the new database

Change the ‘connectionStringName‘ from Local to the connection being used