嘗試在Codesmith Generator(csg)中生成輸出文件。Codesmith - 在與請求的名稱或序號對應的集合中找不到項目
我正在使用ADOXSchemaProvider訪問sql數據庫。 (1 varchar(50)字段)
該消息的語法似乎表明問題是根植於CSG試圖訪問列表/集合中的屬性。其他一些SO問題(CSG未實現)提示使用保留字可能是問題,所以我使用了一堆字母。不是問題。
我已卸載/重新安裝。
目標表的腳本是這樣的
CREATE TABLE [dbo].[tblWitsEnd](
--[Id] [int] IDENTITY(1,1) NOT NULL,
asdf varchar(255) null
) ON [PRIMARY]
GO
錯誤調用堆棧是這樣的
Error: Item cannot be found in the collection corresponding to the requested name or ordinal.
Stack Trace:
at ADOX.Properties.get_Item(Object Item)
at SchemaExplorer.ADOXSchemaProvider.GetTableColumns(String connectionString, TableSchema table)
at SchemaExplorer.TableSchema.#o4c()
at SchemaExplorer.TableSchema.get_Columns()
at _CodeSmith.StartingBlocks30_cst.__RenderMethod1(TextWriter writer, Control control) in G:\csgtemplate.cst:line 113
at CodeSmith.Engine.DelegateControl.Render(TextWriter writer)
at CodeSmith.Engine.Control.RenderChildren(TextWriter writer)
at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer)
at CodeSmith.Engine.CodeTemplate.RenderToString()
at CodeSmith.Engine.Remoting.TemplateSession.#9Hb()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
和線路113我的模板是該代碼段
<% for i = 0 to SourceTable.Columns.Count - 1 step 1 %>
<%= GetSetFieldSnippet(SourceTable.Columns(i)) %>
<% next %>
而且第一線,我確實調查了ADOX提供者是否使用1作爲列索引的基礎。
如果我這樣做,問題仍然存在。
<%= SourceTable.Columns.Clear %>
<%= SourceTable.Columns.Item(0) %>
這有助於回答您的問題嗎? http://stackoverflow.com/questions/24620324/item-cannot-be-found-in-the-collection-corresponding-to-the-requested-name-or-or – Rob
@Rob我不這麼認爲,但很難告訴。據我所知,我認爲這個操作系統有一個基本的SP問題。我以SA身份訪問本地數據庫,所以我懷疑這是一個安全問題。我無法在任何用戶,登錄名,角色屬性中找到安全選項卡。我正在使用Microsoft SQL Server商業智能(64位)12.0.4459.0 – greg