Friday, February 26, 2010

mssql reset table identity

the following script resets the table identity seeding to 99, the next record will have identity of 100

DBCC CHECKIDENT ("[table name]", RESEED, 99);
GO

Friday, February 12, 2010

Monday, February 08, 2010

RadGrid Export Button does not work

if the buttons are located within a RadAjaxPanel or RadUpdatePanel the button must be registered for postback event. This can be done in aspx or code behind:
C#:
ScriptManager.GetCurrent(Page).RegisterPostBackControl(ExportCSVButton);
ASPX:

Thursday, February 04, 2010

sql how to replace the time value in datetime column

update Table1
SET StartDateTime = CONVERT(datetime,
CONVERT(VARCHAR(10),StartDateTime , 101)
+' '+CONVERT(VARCHAR,datepart(HH,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(MI,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(SS,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(Ms,NewStartTime))
)

Wednesday, February 03, 2010

replace time in datetime value c#

I have 2 datetime values: StartDateTime ('11/01/2010 00:00:00') and NewStartTime('12/02/2010 09:30:00 AM'). I want to replace the time value in StartDateTime with the time value in NewStartTime. In order to achieve so I go:
DateTime NewStartDateTime = new DateTime(StartDateTime.Year, StartDateTime.Month, StartDateTime.Day, NewStartTime.Hour, NewStartTime.Minute, NewStartTime.Second);

System.Web.HttpException: Request is not available in this context

this is caused by using "Request["xxx"]"
a quick fix is to use "HttpContext.Current.Request" instead