scholastic/Form2_2.cs
(开头部分) 3KB这里只显示每个文件的开头 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 Form2_2 : Form
{
DataTable mytable;
SqlConnection mycon;
string pstr;
public Form2_2()
{
InitializeComponent();
}
private void Showdata()
{
string constr = "server=.\\sql2005;database=mydata;uid=sa;pwd=sa";
mycon = new SqlConnection(constr);
string mysql = "select * from student";
SqlDataAdapter myada = new SqlDataAdapter(mysql, mycon);
mytable = new DataTable();
myada.Fill(mytable);
dataGridView1.DataSource = mytable.DefaultView;
mycon.Close();
}
private void Form2_2_Load(object sender, EventArgs e)
{
Showdata();
textBox1.Text = mytable.Rows[0][0].ToString(); //赋值
textBox2.Text = mytable.Rows[0][1].ToString();
textBox3.Text = mytable.Rows[0][2].ToString();
textBox4.Text = mytable.Rows[0][3].ToString();
textBox5.Text = mytable.Rows[0][4].ToString();
textBox6.Text = mytable.Rows[0][5].ToString();
textBox7.Text = mytable.Rows[0][6].ToString();
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
pstr = mytable.Rows[e.RowIndex][0].ToString();
textBox1.Text = mytable.Rows[e.RowIndex][0].ToString();
textBox2.Text = mytable.Rows[e.RowIndex][1].ToString();
textBox3.Text = mytable.Rows[e.RowIndex][2].ToString();
textBox4.Text = mytable.Rows[e.RowIndex][3].ToString();
textBox5.Text = mytable.Rows[e.RowIndex][4].ToString();
textBox6.Text = mytable.Rows[e.RowIndex][5].ToString();
textBox7.Text = mytable.Rows[e.RowIndex][6].ToString();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "")
{
后面还有 28 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
