使用自动递增字段更新MySQL中的数据

编程入门 行业动态 更新时间:2024-10-23 21:29:59
本文介绍了使用自动递增字段更新MySQL中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用c#windows窗体构建一个简单的MySQL系统。

I am using c# windows form to build a simple system with MySQL.

我有两个表,定义如下:

I have two tables, defined as follows:

  • 问题
    • questionNum(varchar,pk,not null)
    • questionDes
    • 提示
      answerId(INT,pk,not null,auto increment)
    • answerIncro
    • answerDes
    • eQuestionsNum(fk)

    两种形式:

    • form1( textbox) - questionNum + questionDes + answerDes'按钮'形成2
    • form2(文本框) - questionNum?+提示+ answerIncro'按钮'来完成

    form1 :我知道如何将数据插入问答表,还保存questionNum并转移到form2。

    form1 : I know how to insert data into question and answer table, and also save the questionNum and transfer to form2.

    form2 :我已将数据更新到问题表,但我不知道如何更新答案表(因为answerId是自动增量)。

    form2 : I have updated the data to question table, but I do not know how to update the answer tables (because the answerId is auto increment).

    如果form2上没有questionNum文本框,如何将form2上的数据添加到Form1的questionNum

    and if there is no questionNum textbox on form2, how to add data on form2 to the questionNum of Form1

    有什么建议吗?

    这里我的表格代码2:

    使用System; 使用System.Collections.Generic; 使用System.ComponentModel; 使用System.Data; 使用System.Drawing; 使用System.Linq; 使用System.Text; 使用System.Text; 使用System.Threading.Tasks; 使用System.Windows.Forms; 使用MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data.MySqlClient; 推荐答案

    检查MySQL的 LAST_INSERT_ID ()。类似于MSSQL的SCOPE_IDENTITY()

    Check into LAST_INSERT_ID() for MySQL. Works similar to SCOPE_IDENTITY() for MSSQL

更多推荐

使用自动递增字段更新MySQL中的数据

本文发布于:2023-10-28 18:05:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537377.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   数据   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!