0
我收到錯誤「連接屬性尚未初始化」用下面的代碼尚未初始化:連接使用的SqlCommand時有迷你探查
DbConnection connection = new SqlConnection(connStr);
connection.Open();
connection = new StackExchange.Profiling.Data.ProfiledDbConnection(connection, MiniProfiler.Current);
SqlCommand command = new SqlCommand("GetLanguages", connection as SqlConnection);
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = 240;
command.ExecuteReader();
當它到達Command.ExecuteReader卻() ;線。
如果刪除行
connection = new StackExchange.Profiling.Data.ProfiledDbConnection(connection, MiniProfiler.Current);
然後代碼工作正常。什麼是造成我的執行讀者拋出錯誤的配置數據庫連接?
非常感謝。所以,第二個問題,如果你是親切的...迷你Profiler廣告宣傳與SqlConnection一起工作,我有一堆遺傳代碼,我試圖分析。完整的SqlCommands等什麼是推薦的方式來分析此代碼? – 2013-04-30 15:49:04
@GilesRoberts:正如我在答案中所說的那樣,「從MiniProfiler文檔中我不清楚你是如何使用'ProfiledDbConnection'和'SqlCommand'。」我從未使用過MiniProfiler。 – 2013-04-30 15:50:18