日期:2014-05-17 浏览次数:20737 次
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); } }