
以下是这个窗口的原代码:
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.在查询那里拼多一个学生的过滤条件,数据就是第一步保存的信息。