scholastic/Form4_3.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 Form4_3 : Form
{
DataTable mytable;
SqlConnection mycon;
string pstr;
public Form4_3()
{
InitializeComponent();
}
private void Showdata()
{
string constr = "server=.\\sql2005;database=mydata;uid=sa;pwd=sa";
mycon = new SqlConnection(constr);
string mysql = "select * from teacher";
SqlDataAdapter myada = new SqlDataAdapter(mysql, mycon);
mytable = new DataTable();
myada.Fill(mytable);
dataGridView1.DataSource = mytable.DefaultView;
mycon.Close();
}
private void Form4_3_Load(object sender, EventArgs e)
{
Showdata();
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
pstr = mytable.Rows[e.RowIndex][0].ToString();
}
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("你确定要删除本条记录吗?!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
mycon.Open();
string myupdate = "delete from teacher where 职工号=" + Convert.ToInt32(pstr);
SqlCommand mycom = new SqlCommand(myupdate, mycon);
mycom.ExecuteNonQuery();
mycon.Close();
Showdata();
MessageBox.Show("已成功删除该条数据库记录信息!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
后面还有 7 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
