Hi, I have been trying to get MySQL stored procedures running with the linq templates in Subsonic3. I added some functions to the MySQL.ttinclude file that seems to have generated the stored procedure reference classes. However when I run the code and call the stored procedures I seem to always get NULL results:
public DataSet SPTotalCallsByHour(int period)
{
rt.rtDB ee = new rt.rtDB();
StoredProcedure sp = ee.Totals_By_Hour(period.ToString());
sp.Execute();
return (DataSet)sp.Output;
}
Has anyone got MySQL stored procedures working with Subsonic3? If so can you please explain how you got them to work?
Did you use the ttinclude files straight out of the subsonic 3 release?
These are the two functions I added to the MySQL.ttinclude file:
List<SPParam> GetSPParams(string spName){
var result=new List<SPParam>();
MySqlCommand cmd = new MySqlCommand();
using(conn=new MySqlConnection(ConnectionString))
{
conn.Open();
cmd.Connection = conn;
cmd.CommandText = spName;
cmd.CommandType = CommandType.StoredProcedure;
try
{
MySqlCommandBuilder.DeriveParameters(cmd);
}
catch
{
}
if(cmd.Parameters.Count > 0)
{
foreach(MySqlParameter param in cmd.Parameters)
{
SPParam p = new SPParam();
p.SysType = GetSysType(param.MySqlDbType.ToString());
p.DbType = param.DbType.ToString();
p.Name = param.ParameterName;
p.CleanName=CleanUp(p.Name);
result.Add(p);
}
}
conn.Close();
}
return result;
}
List<SP> GetSPs(){
var result=new List<SP>();
string[] spNames = GetSPList();
foreach(string spName in spNames){
var sp=new SP();
sp.Name=spName;
sp.CleanName=CleanUp(sp.Name);
sp.Parameters=GetSPParams(sp.Name);
result.Add(sp);
}
return result;
}