Discuz!NT官方社区

首页 » Discuz!NT开发与测试 » Discuz!NT插件开发 » Discuz!NT的官方开发团队请进!二次开发的困惑。
hnqdgyj - 2008-6-27 11:53:00


private static DataTable GetTopUsers(DateTime date)
{
string format = " select posterid, poster,count(1) as postcount from {0} where postdatetime >= @startime group by posterid, poster ";
string str2 = " select posterid, poster,sum( postcount ) as sumpostcount from ( {0} ) a group by posterid, poster order by sumpostcount desc,posterid desc ";
DataTable postTableList = currentDataProvider.GetPostTableList();
string str3 = string.Empty;
for (int i = 1; i <= postTableList.Rows.Count; i++)
{
string str4 = BaseConfigs.GetTablePrefix.ToString() + "posts" + i.ToString();
str3 = str3 + " union all " + string.Format(format, str4);
}
str3 = str3.Substring(11);
DataTable table2 = new DataTable();
string commandText = string.Empty;
try
{
string str6 = BaseConfigs.GetDbType.ToLower();
if (str6 == null)
{
return table2;
}
if (!(str6 == "sqlserver"))
{
if (str6 != "mysql")
{
if (str6 != "access")
{
return table2;
}
goto Label_0163;
}
}
else
{
DbParameter parameter = DbHelper.MakeInParam("@startime", DbType.Currency, 8, DateTime.Parse(date.ToString("yyyy-MM-dd")));
commandText = string.Format(str2, str3);
return DbHelper.ExecuteDataset(1, commandText, new DbParameter[] { parameter }).Tables[0];
}
commandText = str3.Replace("@startime", "'" + date.ToString("yyyy-MM-dd") + "'");
commandText = string.Format(str2, commandText);
return DbHelper.ExecuteDataset(1,commandText).Tables[0];
Label_0163:
commandText = str3.Replace("@startime", "#" + date.ToString("yyyy-MM-dd") + "#");
commandText = string.Format(str2, commandText).Replace("sumpostcount desc", "sum( postcount ) desc");
table2 = DbHelper.ExecuteDataset(1, commandText).Tables[0];
}
catch (Exception exception)
{
throw new Exception(exception.Message + str3);
}
return table2;
}


我在编译的时候总是提示参数无效。请官方或高手给我一个具体的参考意见具体见下图。

附件: error.jpg
cobrayang - 2008-6-27 13:56:00
错误提示已经很清楚了,你把1换成System.Data.CommandType.Text或Procedure或其他你要执行的SQL类型即可
1
查看完整版本: Discuz!NT的官方开发团队请进!二次开发的困惑。