mentorList.aspx.cs
上传用户:ah_jiwei
上传日期:2022-07-24
资源大小:54044k
文件大小:2k
源码类别:

数据库编程

开发平台:

Visual C++

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. public partial class student_mentorList : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.            string teacher_id = Request.QueryString["tea_Id"];
  17.         string userId = "63081500007";
  18.   
  19.         SqlConnection connection = DB.connect_la();
  20.         connection.Open();
  21.         //string commandString = "select tea_id from tea_table where tea_name = " + tea_name;
  22.         //SqlCommand cmd1 = new SqlCommand(commandString, connection);
  23.         //SqlDataReader sdr1 = cmd1.ExecuteReader();
  24.         //if (sdr1.Read())
  25.         //    tea_id = sdr1.GetValue(0).ToString();
  26.         //sdr1.Close();
  27.         string commandString = "insert into stu_tea values('" + userId + "','" + teacher_id + "','未选择')";
  28.         SqlCommand cmd = new SqlCommand(commandString, connection);
  29.         try
  30.         {
  31.             cmd.ExecuteNonQuery();
  32.            
  33.         }
  34.         catch
  35.         {
  36.             Response.Write("<script>window.location='messageBoard.aspx'</script>");
  37.         }
  38.         connection.Close();
  39.     }
  40.     //选择导师按钮
  41.     protected void Button_Click(object sender, EventArgs e)
  42.     {
  43.         //string userId = Session["userId"].ToString();
  44.        
  45.     }
  46.   
  47. }