scholastic/Form8_1.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 Form8_1 : Form
    {
        string sno;
        string sname;
        string smajor;
        string sclass;
        string sstate;
        public Form8_1()
        {
            InitializeComponent();
        }

        private void Form8_1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "")
            {
                MessageBox.Show("输入的信息不完整,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string constr = "server=.\\sql2005;database=mydata;uid=sa;pwd=sa";
                SqlConnection mycon = new SqlConnection(constr);
                mycon.Open();
                string myinsert = "insert into state(学号,姓名,专业,所在班级,状态) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')";    //insert插入语句
                SqlCommand mycom = new SqlCommand(myinsert, mycon);   //定义SqlCommand对象,并连接数据库
                mycom.ExecuteNonQuery();
                mycon.Close();
                mycon.Dispose();
                MessageBox.Show("已成功向数据库表中插入一条记录!", "信息提示",MessageBoxButtons.OK, MessageBoxIcon.Information);
                sno = textBox1.Text;
                sname = textBox2.Text;
                smajor = textBox3.Text;
                sclass = textBox4.Text;
                sstate = textBox5.Text;
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
                textBox5.Text = "";
            }
        }

        private void button2_Click(object sender, EventArgs e)
后面还有 17 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。