ÄÚÈÝ·¢²¼¸üÐÂʱ¼ä : 2026/2/4 15:47:57ÐÇÆÚÒ» ÏÂÃæÊÇÎÄÕµÄÈ«²¿ÄÚÈÝÇëÈÏÕæÔĶÁ¡£
¿Î³ÌÉè¼ÆËµÃ÷Êé NO. 6
3£®Éè¼Æ½á¹ûÓë·ÖÎö
3.1ÍøÕ¾½á¹¹ÊµÏÖ
ÔËÐÐMicrosoft Visual Studio 2012Èí¼þ£¬Ð½¨ÃûΪ¡°Web_Exam¡±µÄ¿ÕÍøÕ¾¡£¸ù¾Ý3.2½ÚÉè¼Æ½á¹û£¬ÔÚÍøÕ¾ÏÂн¨Ä¸°æÒ³¼°ÍøÒ³£¬½øÐÐһϵÁеÄÏêϸÉè¼Æ¡¢±àÂëʵÏÖ¡£ £¨1£©µÇ¼ע²áÒ³Ãæ£¬Èçͼ5Ëùʾ¡£
ͼ5 µÇ¼ע²áÒ³Ãæ
using System;
using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI;
using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data.OleDb; using System.Data;
public partial class loginfirst : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) { }
protected void btnlogin_Click(object sender, EventArgs e) {
Response.Redirect(\½øÈëѧÉú×¢²áÒ³Ãæ }
protected void btnlogin2_Click(object sender, EventArgs e)
Éò Ñô ´ó ѧ
¿Î³ÌÉè¼ÆËµÃ÷Êé NO. 7
{
Response.Redirect(\½øÈë½Ìʦע²áÒ³Ãæ }
protected void btn2_Click(object sender, EventArgs e)//½øÈë½Ìʦҳ {
string name = username.Text.Trim(); string psw = password.Text.Trim();
SqlConnection conn = new SqlConnection(\Security=SSPI;database=ѧÉú³É¼¨¹ÜÀí;\
SqlCommand cmd = new SqlCommand(\+ \
DataSet ds = new DataSet(); conn.Open();
SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) {
Session[\ Session[\ Response.Redirect(\ } else
l1.Text = \µÇ½ʧ°Ü!\ }
protected void btn1_Click(object sender, EventArgs e)//½øÈëѧÉúÒ³ {
string name = username.Text.Trim(); string psw = password.Text.Trim();
SqlConnection conn = new SqlConnection(\Security=SSPI;database=ѧÉú³É¼¨¹ÜÀí;\
SqlCommand cmd = new SqlCommand(\\
DataSet ds = new DataSet(); conn.Open();
SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read())
{
Session[\ Session[\ Response.Redirect(\ }
Éò Ñô ´ó ѧ
¿Î³ÌÉè¼ÆËµÃ÷Êé NO. 8
else l1.Text = \µÇ½ʧ°Ü!\ } } } £¨2£©Êý¾Ý¿âÁ¬½Ó ÔÚMicrosoft Visual Studio 2010Èí¼þÖдò¿ª¡¾ÊÓͼ¡¿£¬Ñ¡Ôñ¡¾·þÎñÆ÷×ÊÔ´¹ÜÀíÆ÷¡¿£¬ÓÒ»÷¡¾Êý¾ÝÁ¬½Ó¡¿£¬Ñ¡Ôñ¡¾Ð½¨Á¬½Ó¡¿£¬Ñ¡ÔñÁ¬½Óµ½Score_DataBaseÊý¾Ý¿â¡£ÔÚÍøÕ¾ÏÂÌí¼ÓÅäÖÃÎļþweb.config£¬ÔÚÎļþÖÐÌí¼Ó´úÂ룺 using System.Data.Odbc; using System.Data; using System.Data.SqlClient; SqlConnection conn = new SqlConnection(\ѧÉú³É¼¨¹ÜÀí;\3.2 ÍøÒ³±àÂëʵÏÖ ÔÚWeb_ExamÍøÕ¾ÏÂн¨ÍøÒ³£¬²¢ÒýÓÃÆäÖеÄĸ°æÒ³¡°Master.master¡±¡£ £¨1£©Ñ§Éú×¢²áÒ³Ãæ£¬Èçͼ6Ëùʾ¡£ ͼ6 ѧÉú×¢²áÒ³Ãæ using System; using System.Collections.Generic; using System.Linq; Éò Ñô ´ó ѧ
¿Î³ÌÉè¼ÆËµÃ÷Êé NO. 9
using System.Web; using System.Web.UI;
using System.Web.UI.WebControls; using System.Data;
using System.Data.SqlClient; using System.Data.OleDb;
public partial class ogin : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) { }
protected void butsubmit_Click(object sender, EventArgs e) {
if(Page.IsValid) {
string name = username.Text.Trim(); string psw = password.Text.Trim(); string xuehao = xh.Text.Trim(); string xingming = xm.Text.Trim(); string xingbie = xb.Text.Trim(); string banji = Bj.Text.Trim(); string zhuanye = Zy.Text.Trim(); string sfzh = Sfzh.Text.Trim(); string jia = jtdz.Text.Trim(); string cssj = Rq.Text.Trim();
string sql = \ values(@username,@password,@xh,@xm,@xb,@Bj,@Zy,@Sfzh,@jtdz,@Rq)\
SqlParameter[] parameters = { new SqlParameter(\ new SqlParameter(\ new SqlParameter(\ new SqlParameter(\ new SqlParameter(\ new SqlParameter(\ new SqlParameter(\ new SqlParameter(\ new SqlParameter(\ new SqlParameter(\ };
using (SqlConnection conn = new SqlConnection(\Security=SSPI;database=ѧÉú³É¼¨¹ÜÀí;\
{
Éò Ñô ´ó ѧ
¿Î³ÌÉè¼ÆËµÃ÷Êé NO. 10
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())//tsql {
cmd.CommandText = sql;
cmd.Parameters.AddRange(parameters); cmd.ExecuteNonQuery(); } }
Response.Write(@\×¢²á³É¹¦£¡');\ } }
protected void btnback_Click(object sender, EventArgs e) {
Response.Redirect(\·µ»ØÖ÷½çÃæ } }
£¨2£©ÀÏʦע²áÒ³Ãæ£¬Èçͼ7Ëùʾ¡£
ͼ7 ÀÏʦע²áÒ³Ãæ
using System;
using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI;
using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data.OleDb; using System.Data;
Éò Ñô ´ó ѧ