sai_freestyle 发表于 2012-11-15 11:19

求助Codesmith 连接mysql问题

这两天在研究用Codesmith来自动生成代码提升研发效率。捣腾了半天好不容易让codesmith连接上了mysql,但是在运行模板的时候始终找不到表,从而无法生成模板。

哪个有经验的兄弟帮忙看看。


public ColumnSchema[] GetColumnSchema(String tableName,String connectString)
{
        MySQLSchemaProvider provider = new MySQLSchemaProvider();   
        DatabaseSchema database = new DatabaseSchema(provider,connectString);
        TableSchema []table = provider.GetTables(connectString, database);

        tableName = tableName.ToUpper();
        TableSchema curTable = null;
        int i = 0;
        for(i = 0;i < table.Length;i++)
        {
                curTable = table;

                if (curTable.Name == tableName)
                {
                        break;
                }
        }
        //没找到

        if (i >= table.Length)
        {
                return null;
        }
        ColumnSchema[] cols = null;
        if (curTable != null)
        {
                cols = provider.GetTableColumns(connectString,curTable);
        }
        return cols;
}这个是模板里面获取表的方法,但是始终执行时报找不到表。

sai_freestyle 发表于 2012-11-15 11:21

codesmith 现在可以支持连informix吗?

twtja 发表于 2015-07-07 11:26

本帖最后由 twtja 于 2015-07-07 11:27 编辑

原因其实很简单,就是连接字符串写得不对,应该写成:Server=127.0.0.1;User Id=root;Password=root;Database=test;
页: [1]
查看完整版本: 求助Codesmith 连接mysql问题