C#代码急求!!!

来源:百度知道 编辑:UC知道 时间:2024/06/06 20:17:01
VStudio2008做学生管理系统,就差一个学生界面!要实现通过数据库(SQL2005)
来查询自己的成绩还有学分!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 学生管理系统
{
public partial class student : Form
{
public student()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true) //查询已修学分
{
SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=student;Integrated Security=True");
cn.Open();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
cmd

问题1:
涉及两个页面,
在登录页面中要将登录帐号存在内存中
session["LoginAccount"]=txtLoginName.text;//在登录页面中把登录用户名框的用户名存在内存中

在查询页面中,先从内存中取出用户名
string LoginAccount;
if (session["LoginAccount"]!=null)
LoginAccount=session["LoginAccount"].tostring();
else
response.write("长时间未操作页面信息丢失,请重新登录!");
end if

然后在取数据的SQL语句中加上
" where studentname='"+ LoginAccount+"'";
这样就是谁登录查的谁的学分了

问题二:
用gridview空间
.....
.....
DataSet ds = new DataSet();
da.Fill(ds);
Gridview1.datasource=ds.tables[0];
Gridview1.databind();
这样就将datatable中的数据全部绑定到Gridview控件中了

查到自己的学分
查询语句后面加where 条件啊
select * from table where stuid=001

创建一个类
里面设一个 static 的参数
登陆后 吧学号赋给这个参数
然后在上面查询的时候SQL语句限定ID为你登陆时的学号

我能问下 GetStudentmarkall 是什么东西么?
cmd.CommandText = "GetStudentmarkall";//加条件判断

你用的控件太多了,这样碰到条