exam.aspx.cs

来自「用asp.net开发的考试系统」· CS 代码 · 共 66 行

CS
66
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class exam : System.Web.UI.Page
{
    public int i1=1;
    public int i2 = 1;
    public int i3 = 1;
    public static  int count1;
    public static int count2;
    public static int count3;

    protected void Page_Load(object sender, EventArgs e)
    {
       
        int cid =Convert.ToInt32(Session["kaoshiid"]);
   int did=Convert.ToInt16(Request.QueryString["difficultyid"]);
   int a =Convert.ToInt16(Session["xzt"]);

       int b=Convert.ToInt16(Session["tkt"]);
      int c=Convert.ToInt16(Session["wdt"]);
      
      if (!IsPostBack) {
            string conn = ConfigurationManager.AppSettings["strconn"];
            SqlConnection cn = new SqlConnection(conn);
            cn.Open();
            string sql1="select top "+" "+a+" "+ " "+"* from xuanzeti where kaoshi='"+cid +"' and difficulty='"+did +"' ";
            string sql2 = "select top " + " " + b + " " + " " + "* from tiankongti where kaoshi='" + cid + "' and difficulty='" + did + "' ";
            string sql3 = "select top " + " " + c + " " + " " + "* from wendati where kaoshi='" + cid + "' and difficulty='" + did + "' ";
            SqlDataAdapter da1 = new SqlDataAdapter(sql1, cn);
            SqlDataAdapter da2 = new SqlDataAdapter(sql2, cn);
            SqlDataAdapter da3 = new SqlDataAdapter(sql3, cn);
            DataSet ds = new DataSet();
            da1.Fill(ds, "biao1");
            da2.Fill(ds, "biao2");
            da3.Fill(ds, "biao3");
      
            DataList1.DataSource = ds.Tables["biao1"].DefaultView;
            DataList1.DataBind();
            count1 = ds.Tables["biao1"].Rows.Count;
  
            DataList2.DataSource = ds.Tables["biao2"].DefaultView;
            DataList2.DataBind();
            count2 = ds.Tables["biao1"].Rows.Count;
     
            DataList3.DataSource = ds.Tables["biao3"].DefaultView;
            DataList3.DataBind();
            count3 = ds.Tables["biao1"].Rows.Count;
            cn.Close();




        
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?