public bool isDate(string strDate)
{
string strRegex = @"^\d{1,2}\/\d{1,2}\/\d{2,4}$";
Regex re = new Regex(strRegex);
if (re.IsMatch(strDate))
return (true);
else
return (false);
}
Name Space to be included::::
using System.Text.RegularExpressions;
How to use this function::::::
if (isDate(txtexpirydate.Text) == false)
{
Err_ind = 1;
lblerror.Text = "Check Expiry Date..!";
}
Saturday, 27 September 2008
Monday, 25 August 2008
Try Catch in SQL SERVER 2005
drop proc dbo.P_Product_Name
go
Create proc dbo.P_Product_Name
--P_Product_Name 'Test12'
@Product_Name varchar(100)
as
BEGIN TRY
INSERT INTO T_Table_Test(Product_id, Product_name, today_date)
VALUES(12497, 'Try_Catch',getdate())
END TRY
begin catch
SELECT
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() AS ErrorState,
ERROR_PROCEDURE() AS ErrorProcedure,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage;
end catch
go
Create proc dbo.P_Product_Name
--P_Product_Name 'Test12'
@Product_Name varchar(100)
as
BEGIN TRY
INSERT INTO T_Table_Test(Product_id, Product_name, today_date)
VALUES(12497, 'Try_Catch',getdate())
END TRY
begin catch
SELECT
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() AS ErrorState,
ERROR_PROCEDURE() AS ErrorProcedure,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage;
end catch
Generate Identity Column through Query..
Declare @ProductID int
set nocount on
insert into T_Table_Test(Product_Name,Today_Date) values('Testing',getdate())
SET @ProductId = IDENT_Current('T_Table_Test')
print @ProductId
set nocount on
insert into T_Table_Test(Product_Name,Today_Date) values('Testing',getdate())
SET @ProductId = IDENT_Current('T_Table_Test')
print @ProductId
Friday, 22 August 2008
Wednesday, 20 August 2008
To convert Text into Title Case..
Use following Name Spaces
-------------------------------------------------------------
using System.Globalization;
using System.Threading;
------------------------------------------------------------
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;
Label1.Text = textInfo.ToTitleCase(txttext.Text);
-------------------------------------------------------------
using System.Globalization;
using System.Threading;
------------------------------------------------------------
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;
Label1.Text = textInfo.ToTitleCase(txttext.Text);
Avoid Special Characters
var r={'special':/[\W]/g}
function valid(o,w)
{
o.value = o.value.replace(r[w],'');
}
function valid(o,w)
{
o.value = o.value.replace(r[w],'');
}
For Search Text Box (Execute Search Button by Pressing Enter Key)
function Fun_Search()
{
if (event.keyCode==13)
{
if(document.getElementById('search_txt').value==''||(document.getElementById('search_txt').value)=='Enter the search string')
{
alert('Search string can not be blank.');
return false;
}
document.getElementById('search_btn').disabled=true;
self.location.href='http://www.nitinkumar.com/home/search_new.aspx?find='+document.getElementById('search_txt').value;
return false;
}
}
{
if (event.keyCode==13)
{
if(document.getElementById('search_txt').value==''||(document.getElementById('search_txt').value)=='Enter the search string')
{
alert('Search string can not be blank.');
return false;
}
document.getElementById('search_btn').disabled=true;
self.location.href='http://www.nitinkumar.com/home/search_new.aspx?find='+document.getElementById('search_txt').value;
return false;
}
}
Subscribe to:
Posts (Atom)