【紧急提问】:MySql存储过程脚本中含有预处理语句时,不能执行脚本
## 不含预处理的存储过程
## 存储过程 CustomCount.sql : 取各个表的记录数
Drop Procedure If Exists CustomCount;
Create Procedure CustomCount
  (   
      out RowNum bigint
)
Not Deterministic
SQL Security Definer
Comment ''
Begin   
      Select Count(*) Into RowNum From uc_members;
End;      
------------------------------------  
## 含预处理的存储过程
## 存储过程GetCount.sql: 传入表名,取某个表的记录数 Drop Procedure If Exists GetCount;
Create Procedure GetCount
  (   
      TableName varchar(100)   
      , out RowNum bigint
)
Not Deterministic
SQL Security Definer
Comment ''
Begin   
      Declare SQLStr varchar(2000) default '';
      Set SQLStr = Concat('Select Count(*) Into @MyNum From ', TableName);
      Set @ResultSQL = SQLStr;   
      Prepare preSQL From @ResultSQL;   
      Execute PreSQL;
      Deallocate Prepare preSQL;     
      Set RowNum = @MyNum;
End;    
-------------------------------------    
上述两个存储过程脚本,在C#中读取文件内容后,运行,含预处理的存储过程执行失败。是什么原因呢??    
附件是 .NET Framework 4.0的WinForm运行脚本源码示例,含这两个存储过程。
请修改您的MySql连接字符串即可。
CustomCount.sql中的uc_members表名变可改成您的表名。  
点此下载    
备注:
1. 制作Web安装包时,需要用程序运行MySql脚本,而这些脚本中,经常含有 预处理脚本。
2. 使用这个预处理脚本主要是为了 在动态执行SQL 时取得输出参数的值(类似GetCount.sql中取值)。
3. 不要建议说,使用mysql.exe这个命令一个一个的运行,或者说是调用其它 MySql的.dll或.exe这种方式,因为Web安装时,经常是没有权限取得本地文件的执行权限的。
4. 主要是需要在虚拟主机下进行Web安装。  
谢谢。  
------解决方案--------------------
帮顶http://www.blogjava.net/bingle/articles/70582.html
------解决方案--------------------
加上Shell脚本执行器!