当前位置: 代码迷 >> C# >> 如何按登录的学生帐号窗口来显示学生信息
  详细解决方案

如何按登录的学生帐号窗口来显示学生信息

热度:82   发布时间:2016-05-05 03:20:00.0
怎么按登录的学生帐号窗口来显示学生信息?
像这样,登录的是用第一个学生的学号,但显示出来的是全部学生的信息。求个验证登录学号的代码。
以下是这个窗口的原代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 学生成绩管理系统
{
    public partial class Query_score : Form
    {
           public string strcon;
           public  string strsql;
        public Query_score()
        {
            
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Student form3 = new Student();
            form3.Show();
            this.Close();
        }

        private void chaxun_Click(object sender, EventArgs e)
        {
            strcon = "Server=.;Database=student;Trusted_Connection=SSPI";
            strsql = string.Format("select * from Score where st_nianji like '%" + nianji2.Text + "%'and st_kemu like '%" + kemu.Text + "%'");
            SqlConnection mycon = new SqlConnection(strcon);
            SqlDataAdapter myda = new SqlDataAdapter(strsql, mycon);
            DataSet myds = new DataSet();
            myda.Fill(myds, "Score");
            dataGridView1.DataSource = myds.Tables["Score"];
        }
    }
}
------解决思路----------------------
where条件过滤一下啊
你这光用年级和科目来过滤,跟学号有啥关系?

而且如果你用学号来过滤,那么年级应该就已经是确定的了,不需要再当做查询条件
------解决思路----------------------
增加一个学生帐号查询条件
------解决思路----------------------
1.登录后保存登陆者信息;
2.在查询那里拼多一个学生的过滤条件,数据就是第一步保存的信息。
  相关解决方案