bestlong 怕失憶筆記

當健忘由隨機逐漸趨向常態時,作筆記是非常必要的

Entries for the ‘程式設計’ Category

PHP執行MSSQL預儲程序時出現mssql_bind() [function.mssql-bind]: Unable to set parameter錯誤

出現問題的程式碼如下:

1
2
3
4
5
<?php
$sSQL = "select ..."; //超過 300 個字元的SQL指令
$proc = mssql_init('MyPagingRecordSet', $db_link);
mssql_bind($proc, '@strSQL', $sSQL, SQLVARCHAR, false, false) or print_r(error_get_last());
?>

執行的預儲程序

1
2
3
4
5
6
7
CREATE PROCEDURE MyPagingRecordSet
  @strSQL VARCHAR(1000),  --查詢 sql,如 select * from [user]
  @PageIndex INT = 1,     --查詢的頁號
  @PageSize INT = 30      --每頁顯示紀錄數
AS
--省略內容
GO

不過當 $sSQL 變數內只有很短的 SQL 命令時, 程式是可以正常執行的, 所以改成指定參數長度如下:

1
mssql_bind($proc, '@strSQL', $sSQL, SQLVARCHAR, false, false, 1000) or print_r(error_get_last());

執行結果還是一樣的錯誤訊息, 這應該是字串長度導致的問題, 再把程式改成

1
mssql_bind($proc, '@strSQL', $sSQL, SQLTEXT, false, false) or print_r(error_get_last());

這樣就可以正常執行了, 而 Stored Procedure 的參數的資料型別也可以改成

1
2
3
4
5
6
7
CREATE PROCEDURE MyPagingRecordSet
  @strSQL text,        --查詢 sql,如 select * from [user]
  @PageIndex INT = 1,  --查詢的頁號
  @PageSize INT = 30   --每頁顯示紀錄數
AS
--省略內容
GO

是否要改, 就看執行上是否有其他問題了, 目前沒改也可以執行.

Leave a Comment

31 Days of Refactoring

31天學習重構,透過C#程式碼的示範來學習。主題列表如下:

Refactoring Day 1 : Encapsulate Collection
Refactoring Day 2 : Move Method
Refactoring Day 3 : Pull Up Method
Refactoring Day 4 : Push Down Method
Refactoring Day 5 : Pull Up Field
Refactoring Day 6 : Push Down Field
Refactoring Day 7 : Rename (method, class, parameter)
Refactoring Day 8 : Replace Inheritance with Delegation
Refactoring Day 9 : Extract Interface
Refactoring Day 10 : Extract Method
Refactoring Day 11 : Switch to Strategy
Refactoring Day 12 : Break Dependencies
Refactoring Day 13 : Extract Method Object
Refactoring Day 14 : Break Responsibilities
Refactoring Day 15 : Remove Duplication
Refactoring Day 16 : Encapsulate Conditional
Refactoring Day 17 : Extract Superclass
Refactoring Day 18 : Replace exception with conditional
Refactoring Day 19 : Extract Factory Class
Refactoring Day 20 : Extract Subclass
Refactoring Day 21 : Collapse Hierarchy
Refactoring Day 22 : Break Method
Refactoring Day 23 : Introduce Parameter Object
Refactoring Day 24 : Remove Arrowhead Antipattern
Refactoring Day 25 : Introduce Design By Contract Checks
Refactoring Day 26 : Remove Double Negative
Refactoring Day 27 : Remove God Classes
Refactoring Day 28 : Rename boolean methods
Refactoring Day 29 : Remove Middle Man
Refactoring Day 30 : Return ASAP
Refactoring Day 31 : Replace Conditional with Polymorphism

線上閱讀
http://www.lostechies.com/blogs/sean_chambers/archive/2009/07/31/31-days-of-refactoring.aspx

PDF閱讀
http://www.lostechies.com/media/p/27197/download.aspx

Comments (1)

Java 反編譯工具:jd-gui

JD-GUI is a standalone graphical utility that displays Java source codes of “.class” files. You can browse the reconstructed source code with the JD-GUI for instant access to methods and fields.

JD-GUI is free for non-commercial use. This means that JD-GUI shall not be included or embedded into commercial software products. Nevertheless, this project may be freely used for personal needs in a commercial or non-commercial environments.

http://java.decompiler.free.fr/

Leave a Comment

畫 UML 的工具 – Poseidon for UML Community Edition

http://www.gentleware.com/uml-software-community-edition.html

Leave a Comment

畫 UML 的工具 – astah* community

Lightweight, easy-to-use, and free UML2.1 modeler. You can use it after registration. Go download and try for free.

好像之前是叫做 Jude 吧。

http://www.change-vision.com/
http://astah.change-vision.com/en/
http://astah.change-vision.com/en/product/astah-community.html

網路上找到的舊網址 http://jude.change-vision.com/jude-web/product/community.html

Comments (1)

  • 工商服務

    廣告讀取中...
  • 近期留言

  • 標籤

  • 彙整