With the latest CodeSmith 4.1.3 Professional version bought last week I tried to use the SchemaExlorer on a Sysbase SQL Anywhere database, both Sybase version 9 on a Windows 2003 system, and a Sybase version 10 on a Vista 64bit platform with the following template:
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Description="Sybase test" %>
<%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" Category="Context" Description="Database containing the tables." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
List of tables in database:
<% for (int i = 0; i < SourceDatabase.Tables.Count; i++) { %>
<%= SourceDatabase.Tables
.Name %>
Number of columns<%=SourceDatabase.Tables
.Columns.Count%>
<% } %>
The connection string I use is:
"Provider=ASAProv.90;Password=sql;Persist Security Info=True;User ID=dba;Data Source=TestDB;Location=c:\prj\dft\TestDB.db"
Whenever I try to access some column specific data of a table, CodeSmith crashes with the following error message:
System.Runtime.InteropServices.COMException (0x800A0CC1): Ein Objekt, das dem angeforderten Namen oder dem Ordinalverweis entspricht, kann nicht gefunden werden.
at ADOX.Properties.get_Item(Object Item)
at SchemaExplorer.ADOXSchemaProvider.GetTableColumns(String connectionString, TableSchema table)
at SchemaExplorer.TableSchema.get_Columns()
at _CodeSmith.Test_cst.__RenderMethod1(TextWriter writer, Control control)
at CodeSmith.Engine.DelegateControl.Render(TextWriter writer)
at CodeSmith.Engine.Control.RenderChildren(TextWriter writer)
at CodeSmith.Engine.Control.Render(TextWriter writer)
at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer)
at CodeSmith.Engine.CodeTemplate.RenderToString()
at ej.s()
If I remove the line "Number of columns<%=SourceDatabase.Tables
.Columns.Count%>" from the template, everything runs fine and I can see the names of all the tables within the selected database in the template output.
As the TestDB database contains more than 50 tables with up to 250 columns each, I thought it would be too complex, but the problem also occurs on a newly created database with only one table containing two fields (an integer and a string field).
If you want to test that behaviour, you can download a free developer edition of Sybase SQL Anywhere 10 from the Sybase website.
Any idea how to fix this? There seems to be a problem in the ADOXSchemaProvider.dll, but I don´t have the current source code for this.