วันศุกร์ที่ 3 มิถุนายน พ.ศ. 2554

ตัวอย่างวิธีการใช้งาน function : DataBinder.Eval in Gridview

void productsGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// determine the value of the UnitsInStock field
int unitsInStock =
Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
"UnitsInStock"));
if (unitsInStock == 0)
// color the background of the row yellow
e.Row.BackColor = Color.Yellow;
}
}

วันพุธที่ 25 พฤษภาคม พ.ศ. 2554

ตัวอย่างการสร้าง T-SQL Create TYPE as TABLE

CREATE TYPE MyTableType AS TABLE
(Id INT)
GO
CREATE PROCEDURE MyProcedure
@Ids MyTableType OUTPUT
AS
INSERT INTO @Ids
SELECT object_Id
FROM sys.objects
GO
DECLARE @values MyTableType
exec MyProcedure @Ids=@values OUTPUT
SELECT *
FROM @values
GO
DROP PROCEDURE MyProcedure
GO
DROP Type MyTableType
GO

วันจันทร์ที่ 9 พฤษภาคม พ.ศ. 2554

VMware Error :: Failed to lock the file.

windows มีปัญหา(Blue Screen)ขณะเปิด vmware ใช้งานอยู่ แล้วพอเปิดเครื่องใหม่และเปิด
VMware บอกว่า
"Cannot open the disk or one of the snapshot disks it depends on.Reason: Failed to lock the file."
ทางแก้ปัญหาที่ใช้ได้ผลคือ
ลบ folder .lck ออกให้หมดแล้วเปิด VMware ใหม่ จึงจะกลับมาทำงานได้ปกติ

วันพฤหัสบดีที่ 5 พฤษภาคม พ.ศ. 2554

ตัวอย่าง SQL Server : Custom Order BY

select * from
order by case type
when 'z' then 0
when 'e' then 1
when '3' then 2
else 9 end

-- Prepare sample data
DECLARE @Untouchable TABLE (ID INT, [Month] VARCHAR(13))

INSERT @Untouchable
SELECT 4, 'March' UNION ALL
SELECT 3, 'April' UNION ALL
SELECT 1, 'February' UNION ALL
SELECT 5, 'January' UNION ALL
SELECT 2, 'May'

-- Do the magic
SELECT ID,
[Month]
FROM @Untouchable
ORDER BY CAST([Month] + ' 2007' AS DATETIME)