拼接 Sqlparameter[] 如果 我函数传过来一个 List<SqlParameter>,我想 把他拼接成Sqlparameter[] ,因为 用的SQLHelper? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Sqlparameter[] sqlParams=new Sqlparameter[list.count];sqlParams[1]=list[1];..... 不知道你要实现什么样的。以前我做过这样的。public void CommitAnswer(string level) { //取权限 //BLL.T_Admin.Ht_Level = new BLL.T_Admin().GetPageInfo(); //返回变量 bool R_flag = false; //员工ID string E_id = TES.Common.Helper.Encrypt.ConvertInt(TES.Common.Helper.Encrypt.UrlDecode(Request.QueryString["ID"].ToString())); //得出答案 List<double> LtAmswer = new List<double>(); List<double> LtQuestionValue = new List<double>(); for (int i = 0; i < this.rpQuestion.Items.Count; i++) { RadioButtonList rdbtn = this.rpQuestion.Items[i].FindControl("rbtList_Question") as RadioButtonList; for (int j = 0; j < rdbtn.Items.Count; j++) { if (rdbtn.Items[j].Selected) { LtAmswer.Add(TES.Common.Helper.ConvertHelper.ToDouble(rdbtn.Items[j].Value)); } } //加问题的权重 LtQuestionValue.Add(TES.Common.Helper.ConvertHelper.ToDouble((this.rpQuestion.Items[i].FindControl("HiddenValue") as HiddenField).Value)); } //判断权限进行提交 R_flag = iemployee.TeacherApp_add(Session["LoginID"].ToString(), E_id, level, LtAmswer, LtQuestionValue); if (R_flag) { TES.Common.WebHelper.JScript.AlertAndRedirect("投票完毕", Ht_PageInfo.Rows[0]["PageUrl"].ToString()); //this.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('投票完毕');history.go(-2);self.location.reload();</script>"); } else { TES.Common.WebHelper.JScript.AlertAndRedirect("数据库出错,请联系管理员", Ht_PageInfo.Rows[0]["PageUrl"].ToString()); //this.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('数据库出错,请联系管理员');history.go(-2);self.location.reload();</script>"); } } 2楼回答是否正确Sqlparameter[] sqlParams=new Sqlparameter[list.count];sqlParams[1]=list[1]; arrSQLParams.ToArray();就可以了 大小不固定什么意思 用count实现 不管他里面有几项内容! List<SqlParameter>,本质不就是一个数组吗? C#中泛型 是怎么用的? asp.net接收消息?? 如何在Page_Load事件中改变web主窗口的背景色? 求救:选session还是viewstate来保存这样的数据~ TNND,改版后我相当的不适应!有同感的进! 为什么在BIN文件夹有DLL的文件啊? 如何刷新gridview中的内容 没分了,但还是想问问。。。 关于SESSION的问题 sa登录错误!为什么,我连通没错误呀。哥哥帮忙呀。 一些cookie的问题(cookie同名,domain能有几个点等等) GridView绑定时空格字符消失问题
sqlParams[1]=list[1];
.....
public void CommitAnswer(string level)
{
//取权限
//BLL.T_Admin.Ht_Level = new BLL.T_Admin().GetPageInfo();
//返回变量
bool R_flag = false;
//员工ID
string E_id = TES.Common.Helper.Encrypt.ConvertInt(TES.Common.Helper.Encrypt.UrlDecode(Request.QueryString["ID"].ToString()));
//得出答案
List<double> LtAmswer = new List<double>();
List<double> LtQuestionValue = new List<double>();
for (int i = 0; i < this.rpQuestion.Items.Count; i++)
{
RadioButtonList rdbtn = this.rpQuestion.Items[i].FindControl("rbtList_Question") as RadioButtonList;
for (int j = 0; j < rdbtn.Items.Count; j++)
{
if (rdbtn.Items[j].Selected)
{
LtAmswer.Add(TES.Common.Helper.ConvertHelper.ToDouble(rdbtn.Items[j].Value));
}
}
//加问题的权重
LtQuestionValue.Add(TES.Common.Helper.ConvertHelper.ToDouble((this.rpQuestion.Items[i].FindControl("HiddenValue") as HiddenField).Value));
}
//判断权限进行提交 R_flag = iemployee.TeacherApp_add(Session["LoginID"].ToString(), E_id, level, LtAmswer, LtQuestionValue);
if (R_flag)
{
TES.Common.WebHelper.JScript.AlertAndRedirect("投票完毕", Ht_PageInfo.Rows[0]["PageUrl"].ToString());
//this.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('投票完毕');history.go(-2);self.location.reload();</script>");
}
else
{
TES.Common.WebHelper.JScript.AlertAndRedirect("数据库出错,请联系管理员", Ht_PageInfo.Rows[0]["PageUrl"].ToString());
//this.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('数据库出错,请联系管理员');history.go(-2);self.location.reload();</script>");
}
}
Sqlparameter[] sqlParams=new Sqlparameter[list.count];
sqlParams[1]=list[1];