scholastic/Form6_4.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace scholastic
{
public partial class Form6_4 : Form
{
SqlConnection mycon ;
public Form6_4()
{
InitializeComponent();
}
private void groupBox2_Enter(object sender, EventArgs e)
{
}
private void Form6_4_Load(object sender, EventArgs e)
{
string constr = "server=.\\sql2005;database=mydata;uid=sa;pwd=sa";
mycon = new SqlConnection(constr);
mycon.Open();
SqlCommand mycom = new SqlCommand("select distinct(专业) from class", mycon);
SqlDataReader myread = mycom.ExecuteReader(); //定义SqlDataReader对象并读取数据信息
comboBox1.Items.Clear(); //清空comBox1的数据项
while (myread.Read())
{
comboBox1.Items.Add(myread[0].ToString());
}
myread.Close();
myread.Dispose();
}
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "")
{
MessageBox.Show(this, "专业不能为空,请选择班级!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
string SqlStr = "select * from class where 专业='" + comboBox1.SelectedItem.ToString() + "'";
SqlDataAdapter ada = new SqlDataAdapter(SqlStr, mycon);
DataSet ds = new DataSet();
ada.Fill(ds); //连接数据表格,显示数据
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
}
private void Form6_4_FormClosing(object sender, FormClosingEventArgs e)
{
this.DialogResult = DialogResult.OK;
后面还有 3 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
