2017年9月20日 星期三

SQLServer 抓表名與表註解 | SQLServer select table name and table comments

markdown

```SQL
SELECT c.name '欄位名稱', ep.value AS '欄位備註', t.Name '欄位型態', c.max_length '最大byte', c.precision '總位數', c.scale '小數位數', c.is_nullable '是否可為空', ISNULL(i.is_primary_key, 0) '是否是PK', '/// ' + cast(ep.value as nvarchar(max)) +' '+'\n' + 'public ' + (case when t.Name in ('char','varchar','nvarchar') then 'string' when t.Name in ('datetime','date','time') then 'DateTime' when t.Name = 'decimal' then 'decimal' when t.Name = 'float' then 'float' when t.Name = 'int' then 'int' when t.Name = 'bit' then 'bool' else 'object' end ) +' '+ c.name + '{get;set;}'+'\n' as '類別屬性宣告' FROM sys.columns c INNER JOIN sys.types t ON c.user_type_id = t.user_type_id INNER JOIN sys.objects ON sys.objects.object_id = c.object_id LEFT OUTER JOIN sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id LEFT OUTER JOIN sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id OUTER APPLY fn_listextendedproperty(default, 'SCHEMA', schema_name(sys.objects.schema_id), 'TABLE', sys.objects.name, 'COLUMN', c.name) ep WHERE c.object_id = OBJECT_ID('你的表名字') ``` 20180713 更新加入C#類別屬性宣告字串 用法: 1. 複製到class內 2. 選取剛剛貼上的部分 3. CTRL+H 打開取代 4. 按下正則表達選項 5. 搜尋`\\n` 取代為 `\n` 6. CTRL+E+D 排版

2017年7月17日 星期一

Telerik 舊版本安裝包下載方式 | How to get old version Telerik install package

Telerik 舊版本安裝包下載方式
1.登入官網
2.右上頭像選單→Account OverView

3.Downloads

4.選擇你的安裝框架
5.Version下拉選單切換版本

6.選取Installation安裝檔下載即可

2017年7月13日 星期四

Oracle SQL Developer 使用者設定路徑&顏色設定路徑 | Oracle SQL Developer user setting path & color theme setting path

from
https://stackoverflow.com/questions/7954759/where-does-oracle-sql-developer-store-connections

connection string path

\Users\[user]\AppData\Roaming\SQL Developer\system3.2.20.09.87\o.jdeveloper.db.connection.{version number}\connections.xml

----------
custome color theme setting path

\Users\[user]\AppData\Roaming\SQL Developer\system3.2.20.09.87\o.sqldeveloper.{version number}\product-preferences.xml

find below xml section:
<hash n="SyntaxColorsOptions">
┌   <value n="selectedScheme" v="{your serring name}"/>
│      <list n="styleList">
│      (copy all this section to your new setting file)
└      </list>

           

2017年5月19日 星期五

windows 工作排程器出現"工作排程器太過忙碌,無法處理您的要求,請稍後再試(0x80041323)" | Windows scheduler got Error 0x80041323

主因:
一個CONSOLE程式,裡面塞了一行CONSOLE READLINE()
排程設定時選擇 以平行執行,頻率是兩分鐘一次
造成大量的執行完程式卡在背景
達到了排程器預設的同時執行程式上限
導致其他後面啟動的排程無法執行

所以要注意不要在定時執行的排程寫會讓它卡住的東西
或者不要用工作排程器,改寫AP,以多執行序執行

(
電腦裡排程器執行程式上限的設定檔參照:
https://support.microsoft.com/zh-tw/help/2696472/error-0x80041323-when-running-high-number-of-scheduled-tasks
More Information的部分
)


2017年3月13日 星期一

Visual Studio 加入現有資料夾 | Visual Studio add existing folder to project

問題發生的緣由:
我寫了一個測試程式,後來想說可以不用測試,開始正式寫了,
就用TFS復原功能回朔到初始狀態,因為那些檔案只有建立,還沒第一次commit,
但後來又要繼續測一些東西了,所以要把回朔的測試程式加回來,
結果發現加入現有項目只有加檔案,但是已經在方案資料夾內的資料夾不知道怎麼加入

後來找到解法:
在方案總管上方按鈕找到顯示所有檔案的按鈕,按下

然後在該資料夾路徑處對虛線資料夾按右鍵選加入至專案,
就可以把連同資料夾在內的檔案全部加入了

2016年10月11日 星期二

c# oracle 撈不出資料 但developer撈有資料 | c# oracle can't get data but data can get when query on developer

環境:
VS2013& 類別庫專案 & C# & Oracle.DataAccess 4.121.1.0
情況:
在oracle developer跑一段select  有幾個變數
select blablabla from table where A=:A and B=:B and C=:C
執行結果有資料
但在C#用OracleDataReader撈到DataTable
dt.Load(odr)
撈出來卻沒資料
印出變數跟sql有正確,也沒有跳exception,
查DB的query log也沒看到有執行這段查詢....

解決:
後來發現是變數塞值的時候順序塞錯了
我寫的是
Parameters.Add("A",A)
Parameters.Add("C",C)
Parameters.Add("B",B)
但應該要照順序去塞入
Parameters.Add("A",A)
Parameters.Add("B",B)
Parameters.Add("C",C)
才可以正常的綁定變數

2016年9月1日 星期四

C# 從Oracle db取多個DataTable結果回來 | C# get multi DataTable result from Oracle DB

參考文章:
http://stackoverflow.com/questions/6149836/filling-multiple-datatables-with-1-oraclecommand

簡單來說就是在db上用 SYS_REFCURSOR 輸出結果
用 open cursor for select的方式就可以把結果丟回來
C#端的程式寫法大致上同CALL SP的方式,
參數設定中輸出的資料集是用OracleDbType.RefCursor這個型別