I have been following Joe's video tutorial's on mojoPortal, but have hit a massive speed bump. There seems to be a problem reading the primary key to any of the tables in my schema....this includes standard mojoPortal tables.
I downloaded Codesmith 5.2.2 trial version and tried to open and run one of Joe's mojoPortal cst files - mp_MSSQLStoredProcedureGenerator.cst
I created a SQL Server Native Client 10.0 System DSN :
Microsoft SQL Server Native Client Version 10.50.1600
Data Source Name: MOBY_MSSQL
Data Source Description: MS SQL 2008 R2
Server: MOBY
Use Integrated Security: No
Database: (Default)
Language: (Default)
Data Encryption: No
Trust Server Certificate: No
Multiple Active Result Sets(MARS): No
Translate Character Data: No
Log Long Running Queries: No
Log Driver Statistics: Yes
Statistics File: C:\Users\michael\AppData\Local\Temp\STATS.LOG
Use Regional Settings: No
Use ANSI Quoted Identifiers: No
Use ANSI Null, Paddings and Warnings: No
My connection string to Codesmith studio (Passwords removed) looks like:
Provider=MSDASQL.1;Password=@@@@@@;Persist Security Info=True;User ID=sa;Data Source=MOBY_MSSQL;Mode=ReadWrite;Initial Catalog=mojo
I get an error:
System.Runtime.InteropServices.COMException (0x800A0CB3): Exception from HRESULT: 0x800A0CB3
at ADOX.Keys.get_Count()
at SchemaExplorer.ADOXSchemaProvider.GetTablePrimaryKey(String connectionString, TableSchema table)
at SchemaExplorer.TableSchema.CheckPrimaryKey()
at SchemaExplorer.TableSchema.get_PrimaryKey()
at _CodeSmith.mp_MSSQLStoredProcedureGenerator_cst.__RenderMethod1(TextWriter writer, Control control) in c:\Users\michael\Documents\Visual Studio 2010\Projects\mojoportal\CodeSmithTemplates\Codesmith4x\mp_MSSQLStoredProcedureGenerator.cst:line 36
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()
Line 36 is in Red below:
<%@ CodeTemplate Language="C#" TargetLanguage="T-SQL" Src="" Inherits="CodeSmith.BaseTemplates.SqlCodeTemplate" Debug="True" Description="Template description here." %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
<%@ Property Name="Author" Type="System.String" Default="Joe Audette" Category="Style" Description="Author of stored procedure" %>
<%@ Property Name="IncludeDrop" Type="System.Boolean" Default="True" Category="Options" Description="If true drop statements will be generated to drop existing stored procedures." %>
<%@ Property Name="IncludeInsert" Type="System.Boolean" Default="True" Category="Options" Description="If true insert statements will be generated." %>
<%@ Property Name="IncludeUpdate" Type="System.Boolean" Default="True" Category="Options" Description="If true update statements will be generated." %>
<%@ Property Name="IncludeDelete" Type="System.Boolean" Default="True" Category="Options" Description="If true delete statements will be generated." %>
<%@ Property Name="IncludeSelect" Type="System.Boolean" Default="True" Category="Options" Description="If true Select One will be generated." %>
<%@ Property Name="IncludeSelectAll" Type="System.Boolean" Default="True" Category="Options" Description="If true Select All statements will be generated." %>
<%@ Property Name="IncludeCount" Type="System.Boolean" Default="True" Category="Options" Description="If true a Count Procedure will be generated." %>
<%@ Property Name="InsertSuffix" Type="System.String" Default="_Insert" Category="Style" Description="Suffix to use for all generated INSERT stored procedures." %>
<%@ Property Name="UpdateSuffix" Type="System.String" Default="_Update" Category="Style" Description="Suffix to use for all generated UPDATE stored procedures." %>
<%@ Property Name="DeleteSuffix" Type="System.String" Default="_Delete" Category="Style" Description="Suffix to use for all generated DELETE stored procedures." %>
<%@ Property Name="SelectSuffix" Type="System.String" Default="_SelectOne" Category="Style" Description="Suffix to use for all generated SELECT stored procedures." %>
<%@ Property Name="SelectAllSuffix" Type="System.String" Default="_SelectAll" Category="Style" Description="Suffix to use for all generated SELECT stored procedures." %>
<%@ Property Name="CountSuffix" Type="System.String" Default="_GetCount" Category="Style" Description="Suffix to use for Count stored procedure." %>
<%@ Assembly Name="CodeSmith.BaseTemplates" %>
<%@ Assembly Name="System.Data" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="CodeSmith.BaseTemplates" %>
<% if (SourceTable.PrimaryKey == null) throw new ApplicationException("SourceTable does not contain a primary key."); %>
<% if (IncludeDrop) { %>
Any help would be most appreciated,
Thanks
MikeO