Tuesday, March 24, 2009

Replace enter key value
from textbox using asp.net with c#.net and save in database

Problem: when I wants save multiline textbox value in database using asp.net with c#.net and show as it is its not happening ....
Actually the problem is when we enter the value in textbox and press enter key. value like this
this is dilip
web developer
it save in database but when fetch value from database its showing in same line like this: this is dilip web developer

solution: string txtvalue = mytextbox.Text.ToString().Replace("\r\n", "
");
and save it.
Because enter key value is \r\n . and now it will show as u entered text

Wednesday, March 18, 2009

Return last date of the current month using sql

SELECT datepart(dd,DateAdd(day, -1, DateAdd(month, DateDiff(month, 0, getdate())+1, 0))) AS Dateval

Tuesday, March 17, 2009

How get month name,weekday name,year using sql

RETURN THE WEEKDAYNUMBER
select datepart(dw,getdate()) as weekdaynumber
RETURN THE WEEKDAYNAME
select datename(dw,getdate()) as weekdayname
RETURN THE CURRENTDATENUMBER
select day(getdate()) as currentdatenumber
RETURN THE CURRENTDATE
select GETDATE() as currentdate
RETURN THE CURRENTYEAR
select year(getdate()) as currentyear
RETURN THE CURRENTMONTHNUMBER
select month(getdate()) as currenmonthnumber
RETURN THE CURRENTDATENUMBER
select day(getdate()) as currentddatenumber
RETURN THE MONTHNAME
select datename(mm,getdate()) as currentmonthname

Get 2nd(second) lowest sallery using sql

select top 1 * from (select top 2 * from sallery_tbl order by usallery asc) as Sallery order by USallery desc

where Sallery_tbl is table name and usallery is column name