protected void Button2_Click(object sender, EventArgs e) { Datacon dc = new Datacon(); SqlConnection conn = dc.SQL_con(); if (conn.State == System.Data.ConnectionState.Closed) { conn.Open(); } string url = Request.Url.ToString(); string str = "insert into [shine_sucai_shoucang] (shoucang_id,shoucang_url) values('" + Session["user"] + "','" + url + "')"; SqlCommand comm = new SqlCommand(str, conn); if (Convert.ToInt32(comm.ExecuteNonQuery()) > 0) { // 在此处放置用户代码以初始化页面 string id = Request.Params["suc_dfdfddff"]; WebMessageBox.Show("恭喜,收藏成功!", "sucaiDetail_sub.aspx?suc_dfdfddff=" + id); } else { WebMessageBox.Show("未来收藏!", "Logon.aspx"); } if (conn.State == System.Data.ConnectionState.Open) { conn.Close(); } }
protected void LoginButton_Click(object sender, EventArgs e) { if (lblCheckCode.Text.Trim() != txtCheckCode.Text.Trim()) //判断验证码 { WebMessageBox.Show("验证码不正确,请重新输入!"); } else { string name = UserName.Text.Trim(); string pass = Password.Text.Trim(); Datacon dc = new Datacon(); SqlConnection conn = dc.SQL_con(); if (conn.State == System.Data.ConnectionState.Closed) { conn.Open(); } string str = "select * from userlogin where username='******' and pwd='" + pass + "' "; SqlCommand comm = new SqlCommand(str, conn); SqlDataReader dr = comm.ExecuteReader(); if (name == "" | pass == "") { Response.Write("<script>alert('不能为空!')</script>"); } else if (dr.Read()) { Session["user"] = name; Response.Redirect("index1.aspx"); } else { Response.Write("<script>alert('登录失败!请确保已注册且用户名密码不为空!')</script>"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["NewsId"] != null) { Datacon dacon = new Datacon(); key = Request.QueryString["NewsId"].ToString(); Session["NewsId"] = key; StringBuilder items = new StringBuilder(); string sqlstr = "SELECT MessageName,MessageContent FROM xxfb WHERE (MessagesId = '" + key + "')"; DataSet ds = dacon.getds(sqlstr); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) {//历遍所有的 if (ds.Tables[0].Rows[i]["MessageName"].ToString() != "") this.caption.Text = ds.Tables[0].Rows[i]["MessageName"].ToString(); if(ds.Tables[0].Rows[i]["MessageContent"].ToString() != "") this.editor.Text = ds.Tables[0].Rows[i]["MessageContent"].ToString(); } } else Response.Redirect("InfoOp.aspx"); } }
protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { Datacon db = new Datacon(); string insertpaper = "insert into TaoTi(c_id,PaperName,PaperState,JoinTime,AnswerTime,Score,teacher_id) values(" + int.Parse(ddlCourse.SelectedValue) + ",'" + txtPaperName.Text + "','" + DropDownList2.SelectedValue + "','" + DateTime.Now.ToString() + "','" + DropDownList1.SelectedValue + "', '" + Label21.Text + "','" + Session["ID"] + "')"; int afterID = db.GetIDInsert(insertpaper);//保存试卷,并返回自动生成的试卷编号 if (afterID > 0) { foreach (GridViewRow dr in GridView1.Rows)//保存试卷单选题信息 { string single = "insert into TaoTiDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'单选题'," + int.Parse(((Label)dr.FindControl("Label3")).Text) + "," + int.Parse(SingleFen.Text) + ")"; db.Insert(single); } foreach (GridViewRow dr in GridView2.Rows)//保存试卷多选题信息 { string multi = "insert into TaoTiDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'多选题'," + int.Parse(((Label)dr.FindControl("Label6")).Text) + "," + int.Parse(MultiFen.Text) + ")"; db.Insert(multi); } foreach (GridViewRow dr in GridView3.Rows)//保存试卷判断题信息 { string judge = "insert into TaoTiDetail(PaperID,Type,TitleID,Mark) values(" + afterID + ",'判断题'," + int.Parse(((Label)dr.FindControl("Label7")).Text) + "," + int.Parse(JudgeFen.Text) + ")"; db.Insert(judge); } } Response.Write("<script>alert('添加成功!')</script>"); Response.Write("<script>window.location.href='AddTaoTi.aspx'</script>"); }
public void online() { Datacon dc = new Datacon(); SqlConnection conn = dc.SQL_con(); if (conn.State == System.Data.ConnectionState.Closed) { conn.Open(); } String online1 = HttpContext.Current.Request.UserHostAddress; string strHostName = System.Net.Dns.GetHostName(); string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString(); string str = "insert into [shine_online] (上线地点,ip地址,use_num) values('" + clientIPAddress + "','" + online1 + "','" + Session["user"].ToString() + "')"; SqlCommand comm = new SqlCommand(str, conn); if (Convert.ToInt32(comm.ExecuteNonQuery()) > 0) { } else { } if (conn.State == System.Data.ConnectionState.Open) { conn.Close(); } }
protected void Button1_Click(object sender, EventArgs e) { string pinglun = Request.Form["pingluntext"];//评论信息 if (pinglun.Equals("")) { Response.Write("<script>alert('内容不能为空!')</script>"); } else { for (int i = 0; i < 61; i++) { //改变代码 pinglun = pinglun.Replace("a" + i + ".gif", "<img src=images/face/a" + i + ".gif/>"); } string id = Request.Params["suc_dfdfddff"]; Datacon dc = new Datacon(); SqlConnection conn = dc.SQL_con(); if (conn.State == System.Data.ConnectionState.Closed) { conn.Open(); } string str = "insert into [shine_sucai_pinglun] (sucai_id,pinglun_yonghu,touxiang,pinglun_neirong) values('" + id + "','" + Session["user"] + "','qq.png','" + pinglun + "')"; SqlCommand comm = new SqlCommand(str, conn); if (Convert.ToInt32(comm.ExecuteNonQuery()) > 0) { // 在此处放置用户代码以初始化页面 pingluns(); } else { WebMessageBox.Show("评论出错!", "sucaiDetail_sub.aspx?suc_dfdfddff=" + id); } } }
protected void InitData() { Datacon DB = new Datacon(); int paperID = Convert.ToInt32(Request.QueryString["PaperID"].ToString()); SqlParameter[] Params1 = new SqlParameter[2]; Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型 DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1); GridView1.DataSource = ds1; GridView1.DataBind(); SqlParameter[] Params2 = new SqlParameter[2]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); //题目类型 DataSet ds2 = DB.GetDataSet("Proc_PaperDetail", Params2); GridView2.DataSource = ds2; GridView2.DataBind(); SqlParameter[] Params3 = new SqlParameter[2]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); //题目类型 DataSet ds3 = DB.GetDataSet("Proc_PaperDetail", Params3); GridView3.DataSource = ds3; GridView3.DataBind(); }
protected void LinkButton2_Click1(object sender, EventArgs e) { string id = Request.Params["fdfdfdf"]; String str = ""; Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [shine_sucai] where id=" + id + "", con); DataSet ds = new DataSet(); da.Fill(ds, "shine_message"); if (ds.Tables["shine_message"].Rows.Count == 0) { Response.Write("没有查询到数据,请重试"); } else { Response.Write("<br>"); for (int i = 0; i < ds.Tables["shine_message"].Rows.Count; i++) { str = (ds.Tables["shine_message"].Rows[i]["file_zip_url"]).ToString(); } Response.Redirect("file/zuopin/" + str); } }
//更新多选题的信息 public bool UpdateByProc(int TID) { SqlParameter[] Params = new SqlParameter[8]; Datacon DB = new Datacon(); Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID); //题目编号 Params[1] = DB.MakeInParam("@c_id", SqlDbType.Int, 4, c_id); //科目编号 Params[2] = DB.MakeInParam("@Title", SqlDbType.VarChar, 1000, Title); //题目 Params[3] = DB.MakeInParam("@AnswerA", SqlDbType.VarChar, 500, AnswerA); //答案A Params[4] = DB.MakeInParam("@AnswerB", SqlDbType.VarChar, 500, AnswerB); //答案B Params[5] = DB.MakeInParam("@AnswerC", SqlDbType.VarChar, 500, AnswerC); //答案C Params[6] = DB.MakeInParam("@AnswerD", SqlDbType.VarChar, 500, AnswerD); //答案D Params[7] = DB.MakeInParam("@Answer", SqlDbType.VarChar, 50, Answer); //答案 int Count = -1; Count = DB.RunProc("Proc_MultiProblemModify", Params); if (Count > 0) { return(true); } else { return(false); } }
protected void LinkButton1_Click(object sender, EventArgs e) { //获取客户端的ip地址 string strHostName = System.Net.Dns.GetHostName(); string userip = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString(); //创建cookie对象: if (Session["ipaddress"] == null) { Session["ipaddress"] = userip; Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); //更新语句 con.Open(); String str = "update shine_sucai_zan set dianzan_shu=dianzan_shu+1 where id='1' "; SqlCommand comm = new SqlCommand(str, con); int record = Convert.ToInt32(comm.ExecuteNonQuery()); if (record > 0) { bingdate(); } con.Close(); } }
//根据题目ID 初始化题目 //输入: // TID - 题目编号; //输出: // 题目存在:返回True; // 题目不在:返回False; public bool LoadData(int TID) { SqlParameter[] Params = new SqlParameter[1]; Datacon DB = new Datacon(); Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID); //用户编号 DataSet ds = DB.GetDataSet("Proc_MultiProblemDetail", Params); ds.CaseSensitive = false; DataRow DR; if (ds.Tables[0].Rows.Count > 0) { DR = ds.Tables[0].Rows[0]; this._c_id = GetSafeData.ValidateDataRow_N(DR, "c_id"); //科目编号 this._Title = GetSafeData.ValidateDataRow_S(DR, "Title"); //题目 this._AnswerA = GetSafeData.ValidateDataRow_S(DR, "AnswerA"); //答案A this._AnswerB = GetSafeData.ValidateDataRow_S(DR, "AnswerB"); //答案B this._AnswerC = GetSafeData.ValidateDataRow_S(DR, "AnswerC"); //答案C this._AnswerD = GetSafeData.ValidateDataRow_S(DR, "AnswerD"); //答案D this._Answer = GetSafeData.ValidateDataRow_S(DR, "Answer"); //答案 return(true); } else { return(false); } }
protected void InitData() //读取试题 { SqlParameter[] Params1 = new SqlParameter[2]; Datacon DB = new Datacon(); int paperID = int.Parse(Session["PaperID"].ToString()); Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型 DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1); GridView1.DataSource = ds1; GridView1.DataBind(); ((Label)GridView1.HeaderRow.FindControl("Label27")).Text = ((Label)GridView1.Rows[0].FindControl("Label4")).Text; SqlParameter[] Params2 = new SqlParameter[2]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); //题目类型 DataSet ds2 = DB.GetDataSet("Proc_PaperDetail", Params2); GridView2.DataSource = ds2; GridView2.DataBind(); ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; SqlParameter[] Params3 = new SqlParameter[2]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); //题目类型 DataSet ds3 = DB.GetDataSet("Proc_PaperDetail", Params3); GridView3.DataSource = ds3; GridView3.DataBind(); ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; }
public static string DeleteAll(string s) { string[] str = s.Split('*'); string Tsql = "delete from Chapter where ID='"; for (int i = 0; i < str.Length; i++) { Tsql += str[i] + "'"; if (i + 1 < str.Length) { Tsql += " or ID='"; } } Datacon dataconn = new Datacon(); SqlConnection cn = dataconn.getcon(); cn.Open(); SqlCommand com = cn.CreateCommand(); com.CommandText = Tsql; if (com.ExecuteNonQuery() > 0) { return("true"); } else { return("false"); } cn.Close(); }
//向Score表中添加成绩 //输出: // 插入成功:返回True; // 插入失败:返回False; public bool InsertByProc() { SqlParameter[] Params = new SqlParameter[6]; Datacon DB = new Datacon(); Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, UserID); Params[1] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, PaperID); Params[2] = DB.MakeInParam("@Score", SqlDbType.Int, 4, Score); Params[3] = DB.MakeInParam("@sscore", SqlDbType.Int, 4, sscore); Params[4] = DB.MakeInParam("@mscore", SqlDbType.Int, 4, mscore); Params[5] = DB.MakeInParam("@jscore", SqlDbType.Int, 4, jscore); int Count = -1; Count = DB.RunProc("Proc_ScoreAdd", Params); if (Count > 0) { return(true); } else { return(false); } }
protected void Button1_Click(object sender, EventArgs e) { String title = TextBox1.Text; //获取标题 String validate = TextBox2.Text; //获取验证码 String contents = Request.Form["content1"]; //获取内容 if (contents.Equals("") && title.Equals("") && validate.Equals("")) { Response.Write("<script>alert('不能为空!')</script>"); } else { if (String.Compare(Request.Cookies["yzmcode"].Value, this.TextBox2.Text, true) != 0) { Response.Write("<script>alert('验证码错误!')</script>"); TextBox2.Text = ""; } else { Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); string answerid = ""; int answer_id = 0; //建立数据库连接 if (con.State == System.Data.ConnectionState.Closed) { //如果数据库连接处于关闭状态 则打开数据库 con.Open(); SqlCommand sqlcommand = new SqlCommand("select answerid from Question where id=(select max(id) from Question)", con); answerid = sqlcommand.ExecuteScalar().ToString(); answer_id = int.Parse(answerid); answer_id++; } //创建SQL语句 string sqlstr = "insert into Question(title,question,answerid) values('" + title + "','" + contents + "','" + answer_id + "')"; //创建SQLcommand对象 SqlCommand conmm = new SqlCommand(sqlstr, con); //打开数据库连接 if (Convert.ToInt32(conmm.ExecuteNonQuery()) > 0) { content1.Text = ""; Response.Write("<script> alert('恭喜,发表成功');</script>"); // Response.Redirect("index_forum.aspx"); } else { Response.Write("<script> alert('数据添加失败!');</script>"); } } } }
public void pingluns() { string id = Request.Params["suc_dfdfddff"]; Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [shine_sucai_pinglun] where sucai_id='" + id + "' order by time desc ", con); DataSet ds = new DataSet(); da.Fill(ds, "shine_sucai_pinglun"); con.Close(); }
protected void Page_Load(object sender, EventArgs e) { Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [shine_message] where message_uer='" + Session["user"] + "' and state='未读' ", con); DataSet ds = new DataSet(); da.Fill(ds, "pinglun"); con.Close(); DataList1.DataSource = ds; DataList1.DataBind(); }
public void bingdate() { Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [shine_sucai_zan] ", con); DataSet ds = new DataSet(); da.Fill(ds, "shine_sucai_zan"); con.Close(); DataList5.DataSource = ds; DataList5.DataBind(); }
public void xiaoxi() { Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("select count(id) as num from shine_message where message_uer='3' ", con); DataSet ds = new DataSet(); da.Fill(ds, "shine_message"); con.Close(); DataListaa.DataSource = ds; DataListaa.DataBind(); }
protected void Button_insertinto_Click(object sender, EventArgs e) { Datacon dataconn = new Datacon(); SqlConnection cn = dataconn.getcon(); cn.Open(); SqlCommand com = cn.CreateCommand(); com.CommandText = "update Course set c_name='" + TextBox_c_name.Text.ToString().Trim() + "' where c_id='" + TextBox_c_id.Text.ToString().Trim() + "'"; if (com.ExecuteNonQuery() > 0) { Response.Write("<script>alert('修改成功!" + TextBox_c_name.Text + TextBox_c_id.Text + "');window.parent.location.reload();</script>"); } }
protected void Button_insertinto_Click(object sender, EventArgs e) { Datacon dataconn = new Datacon(); SqlConnection cn = dataconn.getcon(); cn.Open(); SqlCommand com = cn.CreateCommand(); com.CommandText = "update TaoTi set PaperName='" + TextBox_PaperName.Text + "',PaperState='" + TextBox_PaperState.Text + "',AnswerTime='" + TextBox_AnswerTime.Text + "' where PaperID='" + PaperID + "'"; if (com.ExecuteNonQuery() > 0) { Response.Write("<script>alert('修改成功!');window.parent.location.reload();</script>"); } }
protected void Page_Load(object sender, EventArgs e) { Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [pinglun]", con); DataSet ds = new DataSet(); da.Fill(ds, "pinglun"); con.Close(); DataList1.DataSource = ds; DataList1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [shine_sucai] where use_num='" + Session["user"] + "' ", con); DataSet ds = new DataSet(); da.Fill(ds, "shine_sucai"); con.Close(); DataList1.DataSource = ds; DataList1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("select c1=count(id),c2=(select count(id) from shine_message where state='未读' and message_uer='" + Session["user"] + "' ),c3=(select count(id) from shine_message where message_uer='" + Session["user"] + "' ) from shine_message where state='已读' and message_uer='" + Session["user"] + "' ", con); DataSet ds = new DataSet(); da.Fill(ds, "shine_message"); con.Close(); DataList1.DataSource = ds; DataList1.DataBind(); }
protected void updata_datalist() { Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [Question]", con); DataSet ds = new DataSet(); da.Fill(ds, "Question"); con.Close(); DataList1.DataSource = ds; DataList1.DataBind(); }
public int checkDel(string key) { Datacon dacon = new Datacon(); SqlConnection con = dacon.getcon(); string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //SqlCommand myCommand = new SqlCommand("INSERT INTO xxfb(NewsName, NewsContent, NewsDate) VALUES('" + caption + "','" + editor + "', '" + time + "')", con); SqlCommand myCommand = new SqlCommand(" delete from xxfb where MessagesId=@NewsId", con); myCommand.Parameters.Add(new SqlParameter("@NewsId", SqlDbType.Int, 50)); myCommand.Parameters["@NewsId"].Value = key; myCommand.Connection.Open(); int i = (int)myCommand.ExecuteNonQuery(); myCommand.Connection.Close(); return i; }
protected void LinkButton1_Click(object sender, EventArgs e) { String old_pass = TextBox1.Text; String new_pass1 = TextBox2.Text; String new_pass2 = TextBox3.Text; //获取旧密码; Datacon dc = new Datacon(); SqlConnection con = dc.SQL_con(); con.Open(); if (old_pass.Equals("")) { } }
public static string Delete(string s) { Datacon dataconn = new Datacon(); SqlConnection cn = dataconn.getcon(); cn.Open(); SqlCommand com = cn.CreateCommand(); com.CommandText = "delete from Chapter where ID='" + s + "'"; if (com.ExecuteNonQuery() > 0) { return("true"); } else { return("false"); } cn.Close(); }
public bool CheckScore(string XUserID, int XPaperID) { SqlParameter[] Params = new SqlParameter[2]; Datacon DB = new Datacon(); Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, XUserID); Params[1] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, XPaperID); SqlDataReader DR = DB.RunProcGetReader("Proc_ScoreDetail", Params); if (!DR.Read()) { return(false); } else { return(true); } }
public static string Update(string s) { string[] str = s.Split('*'); Datacon dataconn = new Datacon(); SqlConnection cn = dataconn.getcon(); cn.Open(); SqlCommand com = cn.CreateCommand(); com.CommandText = "update Chapter set Name='" + str[1] + "' where ID='" + str[0] + "'"; if (com.ExecuteNonQuery() > 0) { return("true"); } else { return("false"); } cn.Close(); }
//删除成绩 //输入: // XUserID - 用户编号; //输出: // 删除成功:返回True; // 删除失败:返回False; public bool DeleteByProc(int SID) { SqlParameter[] Params = new SqlParameter[1]; Datacon DB = new Datacon(); Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, SID); //成绩编号 int Count = -1; Count = DB.RunProc("Proc_ScoreDelete", Params); if (Count > 0) { return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User_Name"] == null || Session["User_Row"].ToString() != "Teacher") { Response.Write("<script>alert('非法登录!')</script>"); Response.Write("<script language=javascript>top.location.href='../Login.aspx'</script>"); } if (!IsPostBack) { Datacon dataconn = new Datacon(); SqlConnection cn = dataconn.getcon(); cn.Open(); SqlCommand com = cn.CreateCommand(); com.CommandText = "select count(*) from student_score"; int count1 = Convert.ToInt32(com.ExecuteScalar()); Label1.Text = count1.ToString(); cn.Close(); SqlDataSource1.ConnectionString = ConfigurationSettings.AppSettings["connectionstring"].ToString(); SqlDataSource1.SelectCommand = "select * from student_score"; } }
int SQLInsert(string filename1, string filename2, string path) { int i = 0; try { Datacon dacon = new Datacon(); SqlConnection con = dacon.getcon(); SqlCommand myCommand = new SqlCommand("insert into checkRecord(username,filenameS,filenameC,date,QRString,QRLevel,QRVersion,path,IP) values('" + Session["username"] + "','" + filename1 + "','" + filename2 + "','" + DateTime.Now.ToString() + "','" + Label22.Text + "','" + Label26.Text + "','" + Label25.Text + "','" + path + "','" + Label27.Text + "')", con); myCommand.Connection.Open(); i = (int)myCommand.ExecuteNonQuery(); myCommand.Connection.Close(); staticCount(filename1, Session["username"].ToString()); } catch (Exception e) { Label35.Text = "译码结果在查询信息过程出错。错误:" + e.Message; } return i; }