.Net - List Control (DropDownList,RadioButtonList,...) - Demo Example

我們想要以下效果:





代碼:

nsDataSet.BindListControl("stp_DDLYearType", Me.rblYearType, enDropDownListType.Other)
nsDataSet.BindListControl("stp_DDLYearType", Me.ddlYearType, enDropDownListType.All)


說明:

BindListControl是自定義Function,
只需3個parameters分別是 StoredProcedure, ListControl, 自定義選項(本例子用了其他,全部)
無論以後有什麼其他ListControl的需求, 可以很快就做好功能.

...繼續閱讀 »

Dynamic SQL - povit table with row total and column total

Q1, Q2, Q3:





Code:

CREATE TABLE #PovitTable
(
RowHeader varchar(15),
ColumnHeader varchar(20),
VariableValue int
)

INSERT INTO #PovitTable VALUES ('North America','Sales','2000000')
INSERT INTO #PovitTable VALUES ('North America','Expenses','1250000')
INSERT INTO #PovitTable VALUES ('North America','Taxes','250000')
INSERT INTO #PovitTable VALUES ('North America','Profit','500000')
INSERT INTO #P

...繼續閱讀 »

SQL 合併數行資料為一行 Combine Row data to a column

合併Q1中的數行資料為Q2/Q3/Q4.

Combine the row data in Q1 Table to Q2/Q3/Q4.

Q1 = 資料源, table source

Q2 = Example 1

Q3 = Example 2

Q4 = Example 3

個人覺得使用stuff 比 substring 好, 因為不用寫上長度.



Q1,Q2,Q3,Q4 result:





Code:


create table #temp(Staff varchar(50),Department varchar(50))

insert into #temp values('A','IT')
insert into #temp values('B','IT')
insert i

...繼續閱讀 »