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 love2016
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string StrName=textBox1.Text.Trim();
string connection ="Data Source=.;Initial Catalog=DBB;Integrated security=true";
SqlConnection conn=new SqlConnection(connection);
conn.Open();
string cmd = "select SubName from Course inner join Student on Student.StuID=Course.StuID inner join SubInfo on SubInfo.SubID=Course.SubID where StuName='"+StrName+"' ";
SqlDataAdapter data = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
data.Fill(ds);
conn.Close();
dataGridView1.DataSource=ds.Tables [0];
}
private void button2_Click(object sender, EventArgs e)
{
try
{
string StrSub = textBox2.Text.Trim();
string connection = "Data source=.;Initial Catalog=DBB;Integrated security=true;";
SqlConnection conn = new SqlConnection(connection);
string cmd = "select COUNT(StuID)as'dd',AVG(Score)as'cc' from Course inner join SubInfo on Course.SubID=SubInfo.SubID where SubName='" + StrSub + "'";
conn.Open();
SqlDataAdapter data2 = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
data2.Fill(ds);
conn.Close();
dataGridView2.DataSource = ds.Tables[0];
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}
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 love2017
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//string strname = textBox1.Text.Trim();
string strname = comboBox1.Text;
string connection = "data source=.;initial catalog=db;integrated security=true";
SqlConnection conn = new SqlConnection(connection);
string cmd = "select BookName,botime from Borrow inner join Book on book.BookID=Borrow.BookID inner join Reader on Reader.CardID=Borrow.CardID where StuName='"+strname+"'";
conn.Open();
SqlDataAdapter data = new SqlDataAdapter(cmd,conn);
DataSet ds = new DataSet();
data.Fill(ds);
conn.Close();
dataGridView1.DataSource=ds.Tables[0];
}
private void button2_Click(object sender, EventArgs e)
{
string connection = "data source=.;initial catalog=db;integrated security=true";
SqlConnection conn = new SqlConnection(connection);
string cmd = "select BookName,book.BookPub,COUNT(Borrow.BookID)as'借阅次数' from Borrow inner join Book on book.BookID=Borrow.BookID inner join Reader on Reader.CardID=Borrow.CardID group by BookName,book.BookPub";
conn.Open();
SqlDataAdapter data = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
data.Fill(ds);
conn.Close();
dataGridView2.DataSource = ds.Tables[0];
}
private void button3_Click(object sender, EventArgs e)
{
string strname = textBox1.Text.Trim();
string connection = "data source=.;initial catalog=WW;integrated security=true";
SqlConnection conn = new SqlConnection(connection);
string cmd = "select Table_1.体脂比 from Table_1";
conn.Open();
SqlDataAdapter data = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
data.Fill(ds);
conn.Close();
dataGridView1.DataSource = ds.Tables[0];
}
}
}
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 love2016
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string StrName=textBox1.Text.Trim();
string connection ="Data Source=.;Initial Catalog=DBB;Integrated security=true";
SqlConnection conn=new SqlConnection(connection);
conn.Open();
string cmd = "select SubName from Course inner join Student on Student.StuID=Course.StuID inner join SubInfo on SubInfo.SubID=Course.SubID where StuName='"+StrName+"' ";
SqlDataAdapter data = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
data.Fill(ds);
conn.Close();
dataGridView1.DataSource=ds.Tables [0];
}
private void button2_Click(object sender, EventArgs e)
{
try
{
string StrSub = textBox2.Text.Trim();
string connection = "Data source=.;Initial Catalog=DBB;Integrated security=true;";
SqlConnection conn = new SqlConnection(connection);
string cmd = "select COUNT(StuID)as'dd',AVG(Score)as'cc' from Course inner join SubInfo on Course.SubID=SubInfo.SubID where SubName='" + StrSub + "'";
conn.Open();
SqlDataAdapter data2 = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
data2.Fill(ds);
conn.Close();
dataGridView2.DataSource = ds.Tables[0];
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}
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 love2017
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//string strname = textBox1.Text.Trim();
string strname = comboBox1.Text;
string connection = "data source=.;initial catalog=db;integrated security=true";
SqlConnection conn = new SqlConnection(connection);
string cmd = "select BookName,botime from Borrow inner join Book on book.BookID=Borrow.BookID inner join Reader on Reader.CardID=Borrow.CardID where StuName='"+strname+"'";
conn.Open();
SqlDataAdapter data = new SqlDataAdapter(cmd,conn);
DataSet ds = new DataSet();
data.Fill(ds);
conn.Close();
dataGridView1.DataSource=ds.Tables[0];
}
private void button2_Click(object sender, EventArgs e)
{
string connection = "data source=.;initial catalog=db;integrated security=true";
SqlConnection conn = new SqlConnection(connection);
string cmd = "select BookName,book.BookPub,COUNT(Borrow.BookID)as'借阅次数' from Borrow inner join Book on book.BookID=Borrow.BookID inner join Reader on Reader.CardID=Borrow.CardID group by BookName,book.BookPub";
conn.Open();
SqlDataAdapter data = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
data.Fill(ds);
conn.Close();
dataGridView2.DataSource = ds.Tables[0];
}
private void button3_Click(object sender, EventArgs e)
{
string strname = textBox1.Text.Trim();
string connection = "data source=.;initial catalog=WW;integrated security=true";
SqlConnection conn = new SqlConnection(connection);
string cmd = "select Table_1.体脂比 from Table_1";
conn.Open();
SqlDataAdapter data = new SqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
data.Fill(ds);
conn.Close();
dataGridView1.DataSource = ds.Tables[0];
}
}
}