首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

执行存储过程有关问题

2012-09-15 
执行存储过程问题C# codeusing (SqlConnection connection new SqlConnection(WebConfigurationManager.

执行存储过程问题

C# code
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);            }}


上面的程序,执行了就会一直显示刷新的样子,但是没有数据,我在数据库里执行是可以找到数据的,我哪里写错了吗,求指导

[解决办法]
DataTable能獲取到資料嗎
[解决办法]
command.CommandTimeout = 0;这个改大点

热点排行