免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4009 | 回复: 2
打印 上一主题 下一主题

求助Codesmith 连接mysql问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-11-15 11:19 |只看该作者 |倒序浏览
这两天在研究用Codesmith来自动生成代码提升研发效率。捣腾了半天好不容易让codesmith连接上了mysql,但是在运行模板的时候始终找不到表,从而无法生成模板。

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


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

  6.         tableName = tableName.ToUpper();
  7.         TableSchema curTable = null;
  8.         int i = 0;
  9.         for(i = 0;i < table.Length;i++)
  10.         {
  11.                 curTable = table[i];

  12.                 if (curTable.Name == tableName)
  13.                 {
  14.                         break;
  15.                 }
  16.         }
  17.         //没找到

  18.         if (i >= table.Length)
  19.         {
  20.                 return null;
  21.         }
  22.         ColumnSchema[] cols = null;
  23.         if (curTable != null)
  24.         {
  25.                 cols = provider.GetTableColumns(connectString,curTable);  
  26.         }
  27.         return cols;
  28. }
复制代码
这个是模板里面获取表的方法,但是始终执行时报找不到表。

论坛徽章:
0
2 [报告]
发表于 2012-11-15 11:21 |只看该作者
codesmith 现在可以支持连informix吗?

论坛徽章:
0
3 [报告]
发表于 2015-07-07 11:26 |只看该作者
本帖最后由 twtja 于 2015-07-07 11:27 编辑

原因其实很简单,就是连接字符串写得不对,应该写成:Server=127.0.0.1;User Id=root;Password=root;Database=test;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP