Wednesday, July 22, 2009

DB Copy of table

SELECT *
INTO copy_of_testlist
FROM testlist

Wednesday, July 15, 2009

PageMethods

PageMethods.Echo('Hello World!', onComplete, onTimeout, onError, onAbort, context, timeout, priority);

First of all, we must pass all the arguments that the page method is accepting, separated by a comma; in this case, the Echo method accepts one argument, the string to echo. After the list of the server method's arguments, we can pass the references to three methods to call when the page method returns:

•onComplete, is a function that will be called if the page method returns with no errors.
•onTimeout, will be called if the page method doesn't return a value within the specified timeout interval.
•onError, will be invoked if an error occurs during the process of the asynchronous request (for example, an Exception being raised on server-side).
•onAbort, is invoked when the asynchronous request is aborted. This can be done by calling the abort() method on the WebRequest object returned with the call to PageMethods.Echo().
•context, is the state object that will be passed to the callbacks when processing results.
•timeout, specifies the timeout before an asynchronous request is dropped. A response must arrive before the timeout occurs.
•priority, is a number that specifies the priority of the asynchronous request.

DataKeys of gridview

Convert.ToInt32(this.gridview1.DataKeys[row.RowIndex].Values[0])

Thursday, May 28, 2009

Change UPPERCASE to lowercase on the fly

HI MOM, HOW ARE YOU TODAY?

(Shift-F3)

hi mom, how are you today?

(Shift-F3)

Hi mom, how are you today?

Wednesday, May 27, 2009

CSV to Array

// separate individual items between commas
string[] array = commaDelimited.Split(new char[] {','});

Tuesday, April 28, 2009

object[] myArray = new object[] { 1,2,3};
ArrayList = new ArrayList(myArray);

Wednesday, April 22, 2009

COALESCE SQL

COALESCE(expression1,...n) is equivalent to this CASE expression:

SET NOCOUNT ON;
GO
USE tempdb;
IF OBJECT_ID('dbo.wages') IS NOT NULL
DROP TABLE wages;
GO
CREATE TABLE dbo.wages
(
emp_id tinyint identity,
hourly_wage decimal NULL,
salary decimal NULL,
commission decimal NULL,
num_sales tinyint NULL
);
GO
INSERT dbo.wages (hourly_wage, salary, commission, num_sales)
VALUES
(10.00, NULL, NULL, NULL),
(20.00, NULL, NULL, NULL),
(30.00, NULL, NULL, NULL),
(40.00, NULL, NULL, NULL),
(NULL, 10000.00, NULL, NULL),
(NULL, 20000.00, NULL, NULL),
(NULL, 30000.00, NULL, NULL),
(NULL, 40000.00, NULL, NULL),
(NULL, NULL, 15000, 3),
(NULL, NULL, 25000, 2),
(NULL, NULL, 20000, 6),
(NULL, NULL, 14000, 4);
GO
SET NOCOUNT OFF;
GO
SELECT CAST(COALESCE(hourly_wage * 40 * 52,
salary,
commission * num_sales) AS money) AS 'Total Salary'
FROM dbo.wages
ORDER BY 'Total Salary';
GOHere is the result set.

Total Salary

------------

20800.0000

41600.0000

62400.0000

83200.0000

10000.0000

20000.0000

30000.0000

40000.0000

45000.0000

50000.0000

120000.0000

56000.0000