执行存储过程问题

Bottle 2012-09-01 07:55:25
using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString))
{
connection.Open();
//重新赋值SQL语句
//string storedStr = "Exec getxfjdkc @Tempxh='" + userName + "',@nd='" + nd + "',@jb='" + jb + "'";
string storedStr = "getxfjdkc";
SqlCommand command = new SqlCommand(storedStr, connection);
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = 0;
command.Parameters.Add("@Tempxh",SqlDbType.VarChar);
command.Parameters.Add("@nd", SqlDbType.VarChar);
command.Parameters.Add("@jb", SqlDbType.VarChar);

command.Parameters["@Tempxh"].Value = userName;
command.Parameters["@nd"].Value = nd;
command.Parameters["@jb"].Value = jb;

int count = command.ExecuteNonQuery();

SqlDataAdapter adapter = new SqlDataAdapter(command);

DataSet dataSet = new DataSet();
adapter.Fill(dataSet);

DataTable table = dataSet.Tables[0];
foreach (DataRow row in table.Rows)
{
ResultIfo resultIfo = new ResultIfo();
resultIfo.SClass = Convert.ToString(row["kcdlmc"]);
resultIfo.SCode = Convert.ToString(row["kcbm"]);
resultIfo.Subject = Convert.ToString(row["kcmc"]);
resultIfo.Point = Convert.ToString(row["xf"]);
resultIfo.Result = Convert.ToString(row["cj"]);
resultIfo.InsSCode = Convert.ToString(row["tdkcbm"]);
resultIfo.InsSubject = Convert.ToString(row["tdkcmc"]);
resultIfo.InsPoint = Convert.ToString(row["tdxf"]);
resultIfo.InsResult = Convert.ToString(row["tdcj"]);

list.Add(resultIfo);
}
}


上面的程序,执行了就会一直显示刷新的样子,但是没有数据,我在数据库里执行是可以找到数据的,我哪里写错了吗,求指导
...全文
80 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
EnForGrass 2012-09-01
  • 打赏
  • 举报
回复
command.CommandTimeout = 0;这个改大点
Bottle 2012-09-01
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

DataTable能獲取到資料嗎
[/Quote]麻烦能具体点吗,我这是跟网上的教程学的,没发现缺什么呀
zou_yu_lin 2012-09-01
  • 打赏
  • 举报
回复
DataTable能獲取到資料嗎
Bottle 2012-09-01
  • 打赏
  • 举报
回复
自己顶起

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧