我使用VS2012 WPF應用程序vb.net MS Access 2010中我特林通過oledbconnection
執行查詢,它是返回一個錯誤,但是當我通過MS訪問執行相同的查詢它返回表沒有任何問題。哪裏不對?OleDbConnection的執行commad查詢錯誤vb.net
查詢:
SELECT Agents.[PF], Agents.[User_ID], Agents.[First_Name], Agents.[Second_Name], Agents.[Third_Name], Agents.[Family_Name], Agents.[Gender], Agents.[Contract_Type], Agents.Area, Teams.Team_Name, Agents.Hiring_Date, Resignation_Pool.Resignation_Date, Resignation_Pool.Effective_Date, Replace(IIf(Skills.Skill_Directory Is Null,'','Directory, ')+IIf(Skills.Skill_TRC Is Null,'','TRC, ')+IIf(Skills.Skill_Prepaid Is Null,'','Prepaid, ')+IIf(Skills.Skill_Postpaid Is Null,'','Postpaid, ')+IIf(Skills.Skill_KeyAccount Is Null,'','KeyAccount, ')+IIf(Skills.Skill_Blackberry Is Null,'','Blackberry, ')+IIf(Skills.Skill_Broadband Is Null,'','Broadband, ')+IIf(Skills.Skill_Concierge Is Null,'','Concierge, ')+IIf(Skills.Skill_ISP Is Null,'','ISP, ')+IIf(Skills.Skill_Mada Is Null,'','Mada, ')+IIf(Skills.Skill_CSCS Is Null,'','CSCS, ')+'$',', $','') AS Skills FROM ((Agents INNER JOIN Resignation_Pool ON Agents.PF = Resignation_Pool.PF) LEFT JOIN Teams ON Agents.Team = Teams.ID) LEFT JOIN Skills ON Agents.PF = Skills.PF WHERE Agents.Contract_Status = 'Active'
錯誤:
Fill: SelectCommand.Connection property has not been initialized.
代碼:
Dim SQL10 As New OleDb.OleDbCommand("SELECT Agents.[PF], Agents.[User_ID], Agents.[First_Name], Agents.[Second_Name], Agents.[Third_Name], Agents.[Family_Name], Agents.[Gender], Agents.[Contract_Type], Agents.Area, Teams.Team_Name, Agents.Hiring_Date, Resignation_Pool.Resignation_Date, Resignation_Pool.Effective_Date, " & Sql & " FROM ((Agents INNER JOIN Resignation_Pool ON Agents.PF = Resignation_Pool.PF) LEFT JOIN Teams ON Agents.Team = Teams.ID) LEFT JOIN Skills ON Agents.PF = Skills.PF WHERE Agents.Contract_Status = 'Active'")
Dim DataAdapter10 As New OleDb.OleDbDataAdapter(SQL10)
Dim DataTable10 As New DataTable()
DataAdapter10.Fill(DataTable10)
的問題不在於你的查詢,但與沒有正確設置你的連接你的'Command'對象。仔細閱讀錯誤':)' – 2013-03-11 11:24:01
請你告訴我們你對你如何調用查詢代碼? – wizzardz 2013-03-11 11:28:26
檢查我編輯的命令Q – KaZzA 2013-03-11 11:28:55