codesmith and stored procedures problem

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
8/21/2010 11:05:17 PM
Gravatar
Total Posts 2

codesmith and stored procedures problem

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

8/22/2010 6:16:14 AM
Gravatar
Total Posts 18439

Re: codesmith and stored procedures problem

Hi,

I don't know about all that system dsn business and using the ADOXSchemaProvider.

I use the normal SqlSchemaProvider and I enter my connection string the same as in my mojoportal installation like this:

server=localhost\SQLExpress;UID=sa;PWD=xxxxx;database=mojodev2

It works fine for me.

Hope it helps,

Joe

8/22/2010 6:27:10 AM
Gravatar
Total Posts 2

Re: codesmith and stored procedures problem

I've spent a fair amount of time on this, but I eventually worked out that CodeSmith 5.2.2 will not work with an ADOX connect to a SQL Server 2008 R2 DB.

I managed to get it to work with an SqlSchemaProvider Data Source. Perhaps this is due to the latter returning the dbo.* portion of the table name - but this is just a hunch. 

You must sign in to post in the forums. This thread is closed to new posts.