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 Form7query : Form { SqlCommand cmd; public Form7query(SqlCommand cmd) { InitializeComponent(); this.cmd = cmd; } private void button1_Click(object sender, EventArgs e) {
Form8count f8 = new Form8count(); f8.ShowDialog(); } private void btninquire_Click(object sender, EventArgs e) { cmd.CommandText = "select * from students where 班级 = '" + comclass.Text.Trim() + "'"; SqlDataReader sq = cmd.ExecuteReader(); while (sq.Read()) { //txtname.Text = sq["name"].ToString(); //txtsex.Text = sq["sex"].ToString(); //txtage.Text = sq["age"].ToString(); //txtclass.Text = sq["class"].ToString(); //txtaddress.Text = sq["address"].ToString(); //txtphone.Text = sq["phone"].ToString(); } sq.Close(); }
private void btncancel_Click(object sender, EventArgs e) { this.Close(); }
private void Form7query_Load(object sender, EventArgs e) { string ss = "select * from students"; cmd.CommandText = ss; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; }
}}
namespace 学生信息管理{ public partial class Form7query : Form { SqlCommand cmd; public Form7query(SqlCommand cmd) { InitializeComponent(); this.cmd = cmd; } private void button1_Click(object sender, EventArgs e) {
Form8count f8 = new Form8count(); f8.ShowDialog(); } private void btninquire_Click(object sender, EventArgs e) { cmd.CommandText = "select * from students where 班级 = '" + comclass.Text.Trim() + "'"; SqlDataReader sq = cmd.ExecuteReader(); while (sq.Read()) { //txtname.Text = sq["name"].ToString(); //txtsex.Text = sq["sex"].ToString(); //txtage.Text = sq["age"].ToString(); //txtclass.Text = sq["class"].ToString(); //txtaddress.Text = sq["address"].ToString(); //txtphone.Text = sq["phone"].ToString(); } sq.Close(); }
private void btncancel_Click(object sender, EventArgs e) { this.Close(); }
private void Form7query_Load(object sender, EventArgs e) { string ss = "select * from students"; cmd.CommandText = ss; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; }
}}