string pConStr = "datasource=127.0.0.1;username=root;password=shi123;database=test;charset=utf8";
try
{
MySqlConnection pMysqlConnection = new MySqlConnection(pConStr);
//连接数据库
pMysqlConnection.Open();
//MessageBox.Show("success");
//定义变量
int pSID;
string pName = textBox2.Text;
int pChinese = Convert.ToInt32(textBox3.Text);
int pMath = Convert.ToInt32(textBox4.Text);
int pEnglish = Convert.ToInt32(textBox5.Text);
pSID = Convert.ToInt32(textBox1.Text);
//插入成绩单
string pMysqlInsert1 = "INSERT INTO `成绩表`(`学号`,`语文`,`数学`,`英语`) VALUES(@pSID,@pChinese,@pMath,@pEnglish);";
C# MySQL 插入变量
最新推荐文章于 2025-03-22 15:37:33 发布