scholastic/Form3_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 Form3_1 : Form
{
string sno; //存储课程号
string sname; //存储课程名
string steacher; //存储授课老师
string sspec; //存储专业
public Form3_1()
{
InitializeComponent();
}
private void Form3_1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == ""||textBox4.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 course(课程号,课程名,任课教师,专业) values(" + Convert.ToInt32(textBox1.Text) + ",'" + textBox2.Text + "','" + textBox3.Text + "','"+textBox4.Text+"')";
SqlCommand mycom = new SqlCommand(myinsert, mycon);
mycom.ExecuteNonQuery();
mycon.Close();
mycon.Dispose();
MessageBox.Show("已成功向数据库表中插入一条记录!","信息提示",MessageBoxButtons.OK, MessageBoxIcon.Information);
sno = textBox1.Text;
sname = textBox2.Text;
steacher = textBox3.Text;
sspec = textBox4.Text;
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
}
private void button2_Click(object sender, EventArgs e)
{
Form3_1_ myf = new Form3_1_();
myf.toolStripStatusLabel1.Text = "成功插入一条记录-->课程号:" + sno + ",课程名:" + sname + ",任课教师:" + steacher + ",专业:" + sspec;
后面还有 14 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
