Search code examples
sql-servervb.netsql-server-2008mygeneration

Why is MyGeneration stored procedure generator template not working?


I downloaded the stored procedure generator template from this link:

http://www.mygenerationsoftware.com/TemplateLibrary/Template/?id=10998336-5037-496c-a163-050060de065a

Basically it generates Insert, Update, Delete, Select and LoadByPrimaryKey stored procedures by reading the schema.

However, when I run it is not working. I get error at this line:

For Each objColumn In objTable.PrimaryKeys

and the error that I get is:

Object doesn't support this property or method

Has anybody faced this problem? How do I resolve this?


Solution

  • The template code is not running through enumerations. Not sure whether this is a MyGeneration problem or a VBScript problem. In any case, in the template change code like this:

    For each objColumn In objTable.PrimaryKeys
    

    Change to:

    For j=0 to objTable.PrimaryKeys.Count - 1
        Set objColumn = objTable.PrimaryKeys(j)
    

    There are also instances of code like this:

    For each objColumn In objTable.Columns
    

    Change to:

    For j=0 to objTable.Columns.Count - 1
        Set objColumn = objTable.Columns(j)
    

    This worked for me (Windows 7, .Net 4.0, Sql Server 2008 R2, MyGeneration 1.3.1.1).