ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
雖然ODBC 已經很少使用了, 但是偶爾還是會遇到舊的資料庫配合新的程式...
我就遇到這個問題了, 解決方式是參考:
http://dacosta9.wordpress.com/2011/10/27/error-im014-microsoftodbc-driver-manager-the-specified-dsn-contains-an-architecture-mismatch-between-the-driver-and-application/
就是在 32-bit, 64-bit 都設定相同的DSN 就可以了!!
2013年7月16日 星期二
如何解決ERROR [IM014] [Microsoft][ODBC Driver Manager] ...
2013年2月1日 星期五
Crystal Report for Visual Studio 2012 終於出來了!!
ya~ Crystal Report for Visual Studio 2012 終於出來了!!
http://scn.sap.com/docs/DOC-35074
2012年12月18日 星期二
Windows Store App 建置及部署時發生錯誤
偶爾Visual Studio 2012在部署時會發生錯誤, 如上圖
通常都是模擬器不知怎麼了
我的處理方式就是關閉模擬器,再試一次通常就沒問題了
最多是Visual Studio 2012 關閉重開, 就OK啦~
2012年12月14日 星期五
解決ASP.NET WEB API get 方法 overload 的問題
如果你想寫一支程式存取某個網頁的內容, 尤其是那些知名網站ex. facebook , google maps api ...
最簡單的方式就是使用 web api 了
web api 是一種RESTful架構, 利用 http 的 request (GET, POST, PUT, DELETE)進行資源的存取 (包含查詢, 新修刪...等)
在Microsoft的技術中早先可以使用 WCF 建構 Web API
現在在asp.net 4.5 中也可以建構web api ,
你可以參考:
http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
step1:建立 mvc4 web application

step2: 選擇web api

step3: ValueControllers.cs

step4: test (Ctrl+F5)

得到的結果是: ["value1","value2"]
原則上取名為GetXX的方法自動會執行HTTP-Get Method
不管你的GetXXX有幾個都是視為相同的overloads
所以如果你需要Get兩組相同組合的內容時, 就會出現問題了,
Ex.
GetById (string id) 及 GetByName(string Name)那怎麼辦呢?
這時就要使用Attributes, 細節請參考:
http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-and-action-selection
簡單的來說, 就是使用[HttpGet]及[ActionName]再加 Routes 的設定
step1: 設定 [HttpGet]及[ActionName]
// GET api/values
public IEnumerable GetAll()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
public string GetById(int id)
{
return "value";
}
// GET api/values/age/10
[HttpGet]
[ActionName("age")]
public IEnumerable GetByAge(int arg1)
{
return new string[] { "aaa", "bbb" };
}
// GET api/values/size/10
[HttpGet]
[ActionName("Size")]
public IEnumerable GetBySize(int arg1)
{
return new string[] { "LL", "MM" };
}
// GET api/values/name/departement1/anita
[HttpGet]
[ActionName("name")]
public IEnumerable GetByName(string arg1, string arg2)
{
return new string[] { "department", "username" };
}
step2: 開啟WebApiConfig.cs, 設定Routespublic static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "ActionApi",
routeTemplate: "api/{controller}/{action}/{arg1}/{arg2}" ,
defaults: new { arg2 = RouteParameter.Optional }
); //<< 加上這段
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
示範與結果:
http://localhost:33417/api/values/
會走 DefaultApi, 進入GetAll()方法
得到 ["value1", "value2"]
http://localhost:33417/api/values/100
會走 DefaultApi, 進入GetById()方法
得到 "value1"
http://localhost:33417/api/values/age/10
會走 ActionApi, 進入GetByAge(10)方法
得到 [ "aaa", "bbb"]
http://localhost:33417/api/values/size/10
會走 ActionApi, 進入GetBySize(10)方法
得到 [ "LL", "MM"]
http://localhost:33417/api/values/name/sd/anita
會走 ActionApi, 進入GetByName("sd", "anita")方法
得到 ["department", "username"]
2012年12月1日 星期六
WCF 的 DataMember 可否序列化成JSON 格式
WCF 的 DataMember 可否序列化成JSON 格式?
可以的!
有人已經寫好範例, 就參考這個吧!
http://stackoverflow.com/questions/2086666/wcf-how-do-i-return-clean-json
2012年11月24日 星期六
如何關閉wcf service host
每次在測試 WCF Service Library 時Visual Studio 會貼心的幫我們建立Host及Test程式來測試WCF服務的功能
但是當我們自行建立Host時, 這個自動建立的Host也會被啟動而佔用了指定的Port
這時只要將WCF Service Library 專案中的WCF Opiotns 頁中的 Start WCF Service Host when debugging another project in the same solution關閉即可~
2012年11月15日 星期四
最新技術參考網址
Windows Store App: http://msdn.microsoft.com/zh-tw/windows
download: http://msdn.microsoft.com/en-us/windows/apps/br229516
Windows Azure: http://www.windowsazure.com
resources: http://www.windowsazure.com/en-us/develop/net/
Live SDK: http://msdn.microsoft.com/en-US/live/ff621310
2012年11月7日 星期三
Windows 8 鍵盤快捷鍵
Windows 8 鍵盤快捷鍵
常用工具列:Windows 鍵 + C
搜索:Windows 鍵 + Q
分享:Windows 鍵 + H
開始:Windows 鍵
裝置:Windows 鍵 + K
有關搜尋則還有細部的快捷鍵:
搜尋設定:Windows 鍵 + W
尋找檔案:Windows 鍵 + F
http://3c.msn.com.tw/article/1210300058/1
2012年11月1日 星期四
學會Windows 8不難~
Windows 8 操作12字口訣
觸控四邊, 滑鼠四角, 右鍵無敵
http://events.tw.msn.com/windows/windows-8-%e6%93%8d%e4%bd%9c12%e5%ad%97%e5%8f%a3%e8%a8%a3
2012年6月18日 星期一
在Windows 8 找不到你的程式嗎?
像是 “notepad"
現在 [開始] 選單不見了, 讓人不知所措,
其實, 只要滑鼠移到時間的右側, 就會看到 [搜尋],
直接在上頭輸入要找的應用程式名稱就可以了!!
2012年6月1日 星期五
2011年11月19日 星期六
終於有WPF 版的Crystal Report Viewer
最近有空試了一下Crystal Report for Visual Studio 2010 的功能
看到文件上有關於WPF 版的Crystal Report Viewer的控制項,
測試了一下發現,
CrystalReportViewer for WPF的控制項竟沒有ReportSource的屬性,
啊~這樣要怎麼把報表物件塞入呢?...
找了半天才看到它有個ViwerCore屬性, 下有個ReportSource屬性,
真是曲折...
要這樣寫才能塞Report Object :
reportViewer.ViewerCore.ReportSource = new CrystalReport1();
2011年11月18日 星期五
Crystal Report 2011 與 Visual Studio 2010 的問題
Visual Studio 2010 不再內鍵 Crystal Report的元件 (之前曾提過)
很多人說有啊!!
的確你可以在Visual Studio 2010 中可以看到Crystal Report 專案範本,
不過開啟打開之後你就知道了, Crystal Report 的元件必須另外下載.
但也別太為難, 下載安裝之後就可以使用, 並不需要額外購買授權.
最近在使用Crystal Report 2011 與 Visual Studio 2010
意外發現, 安裝Crystal Report 2011 之後, 在Visual Studio 2010中並沒Crystal Report 元件的蹤跡, 看了文件之後,
真象大白 (以下copy 自SAP SAP® CRYSTAL SOLUTIONS 2011常見問題集):
SAP Crystal Reports 2011 不再加入開發工具。應用程式設計介面 (API) 則會隨附在
SAP Crystal Reports (適用於 Eclipse 的版本,適合 Java 開發人員) 及 SAP Crystal
Reports (適用於 Visual Studio2010 的版本,適合 .NET 開發人員) 這些產品中。
也就是說, 如果有Crystal Report 2011, 但仍要在Visual Studio 2010 進行開發, 也一樣要安裝SAP Crystal Reports (適用於 Visual Studio2010 的版本,適合 .NET 開發人員).
另外, 我做了一個實驗, 建立一般的專案, 在工具箱中要加入Crystal Report Viewer 竟然不行...
難道只能使用Crystal Report Application 範本建立嗎?
仔細看了工具箱的文字提示才發現, 原來Crystal相關元件必須使用.NET Framework 4(一般專案是用.NET Framework 4 Client Profile), 改過來後就可以用了.
2010年12月4日 星期六
WPF 在 XAML 中靜態成員的參考
參考物件成員
在XAML 中如果要Binding 某個物件時, 可以在Resources 中定義邏輯資源, Ex:
圖中被圈選這行會在初始化時在記憶體建立一個型別為Product的物件 (呼叫其建構函式). 在XAML中參考這個資源時, 可以使用StaticResource 或是 DynamicResource 關鍵字.
參考靜態成員
但如果類別只有靜態成員 (且不可呼叫instance 的建構函式), 又要Binding 到控制項時, 就不能使用將之定義在邏輯資源中了. 因為會在初始化時呼叫建構函式時出現錯誤.
這時後就要用{x: Static 類別.靜態成員}, Ex:
2010年10月23日 星期六
圖檔放在dll 中, 如何在網頁中動態參考?
這是同學在ASP.NET課程問的問題.
解法
step1: 建立Class Library
step2: Add Reference : System.Web
step3: 將圖檔放入專案中, 並設定檔案屬性為 – Embedded Resource
step4: 在Class1.cs 的 Class 之前 宣告 WebResource
using System.Web.UI;
[assembly: WebResource("命名空間.圖檔.gif", "image/gif")]
step5: Build 專案
step6: 在Web Site –> Add Reference –> step1 的 Class Library
step7: 在網頁上放入Image或ImageButton
step8: 在Page_Load 事件 --
Page.ClientScript.RegisterClientScriptResource(typeof(MyScript.Class1), "MyScript.button_more07.gif");
ImageButton1.ImageUrl = ClientScript.GetWebResourceUrl(typeof(MyScript.Class1), "MyScript.button_more07.gif");
完成.
2010年10月8日 星期五
WPF MVVM 的專案Template 下載
開發WPF應用程式的Design Pattern – Model-View-ViewModel.
若要開發需自行從WPF 應用程式專案建立MVVM所需的基本內容, 如果需要像ASP.NET 的MVC 從專案範本建立, 可以從 New Project 的左邊畫面按 [Online] –> WPF , 右邊畫面 雙擊 [WPF MVVM Application] 即可下載安裝這個範本 .
建立專案之後便可看到Solution Explorer 已經先建立好必要的目錄及類別:
2010年7月6日 星期二
2010年6月11日 星期五
ASP.NET Chart 控制項部署問題
最近將有包含用到Chart 控制項進行部署到iis, 部署後執行出現這個錯誤:
跟著網頁提示的錯誤訊息進行修正:
- 在Web.config 的<system.webServer>區段加上:
<validation validateIntegratedModeConfiguration="false"/> - 配合以下設定, 在C磁碟建立 TempImageFiles 目錄:
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</appSettings>
重新部署後就可以順利執行了!!
2010年3月30日 星期二
VS2010 的 Crystal Report 不見了!
負責Crystal Report 產品的同事告訴我說, VS2010裡不會在放Crystal Report, 必須另外下載!
拿到VS2010 Beta 時打開VS的專案範本, 有看到Crystal Report的範本:
一直很疑惑, 有啊!! 還在啊!!
昨天心血來潮真的去開一個Crystal Report的專案, 得到這個畫面:
果然, 需要另外下載…
是 Microsoft 有了自家的 Report 產品, 就不主動內建Crystal Report , 還是其他原因呢? (不得而知)
不過, 至少還留著專案範本, 留個Download 的 Link 位置, 也算是一種友善吧!!
2010年3月25日 星期四
WPF資料繫結的驗證方式
WPF資料繫結的驗證方式作法有三種:
- 使用ValidationRules
- 使用ValidatesOnDataErrors
- 使用ValidatesOnDataException
這三種方式都是Bindng物件的屬性, 作法卻不大相同.
使用ValidationRules
必須建立一個類別並繼承ValidationRule, 在裡頭的Validate方法撰寫驗證程式碼.
然後在XAML上必須這樣寫:
<DatePicker Grid.Column="1" Grid.Row="2" Name="DatePicker1" >
<DatePicker.SelectedDate>
<Binding Path="CreationTime">
<Binding.ValidationRules>
<local:DateRangeValidationRule />
</Binding.ValidationRules>
</Binding>
</DatePicker.SelectedDate>
</DatePicker>
這是最早出現的作法(.net 3.0), 好處是驗證邏輯是獨立的類別可以重複使用, 缺點是太複雜了!!
***Silverlight 並不支援這種做法.***
使用ValidatesOnDataErrors
只要在資料來源的類別中實作IDataErrorInfo介面, 在Item索引子中實作檢查欄位驗證的邏輯.
然後只要設定Binding物件的ValidatesOnDataErrors屬性為True就會有效果.
.net 3.0sp1以後才有的功能. 好處是可以直接在資料來源的類別實作檢查欄位驗證的邏輯. 缺點是驗證邏輯無法重複使用 (不過驗證邏輯需要重複使用的機會有多少?).
***Silverlight有支援這種做法.***
使用ValidatesOnDataException
直接在資料來源的類別中的屬性的Set區段中撰寫驗證邏輯, 並在驗證發生問題時丟出錯誤(throw exception)
但在XAML中要設定ValidatesOnDataException為True及ValidationRules指為ValidatesOnExceptions.
<Binding Path="CreationTime" ValidatesOnDataException=True>
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
.net 3.0sp1以後才有的功能. 好處是類別的程式碼寫法比較直覺, 也不需實作任何介面. 缺點是還是要手動打XAML(Visual Studio 2010有Binding 的屬性視窗, 但並沒有ValidationRules的選項, 所以要自己打XAML)
***Silverlight有支援這種做法.***







