我需要使用 while 循环将 10 个单选按钮值放入 vb.net 的插入语句中

发布于 2024-08-19 06:52:08 字数 198 浏览 3 评论 0原文

我有 10 个具有是/否值的单选按钮。这些是一题的选项,所以需要在数据库中下1条记录。 所以 - 问题 1 是,问题 1 否,问题 1 是,依此类推。 我想使用 while 循环或其他循环来获取所有这些值并将它们插入或更新到数据库中以解决该特定问题。任何想法。我是编程新手。 数据库表是 ID、问题、答案。 所以这将是 1 个问题 1 是,2 个问题 1 是,3 个问题 1 否。

i have 10 radio buttons that have yes/no values. These are options to one question, so need to in the database under 1 record.
so - question1 yes, question 1 no, question1 yes and so on.
i want to use a while loop or some other loop to take all these values and insert them or update them in the database for that particular question. any ideas. i m new to programming.
the db table is ID, question, Answer.
so it will be 1 question1 yes, 2 question1 yes, 3 question1 no.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三月梨花 2024-08-26 06:52:08

您是新手,因此当您更有信心时这可能会对您有所帮助,但您可以做的一件事是在代码隐藏中创建一个单选按钮数组。然后,您可以遍历单选按钮数组,将其信息提取到数据库中。

但是,如果单选按钮不会更改,那么最好只是对插入进行硬编码。

You are new, so this might help you when you are a little more confident, but one thing you can do is create an Array of the radio buttons in your codebehind. You can then iterate through the array of radiobuttons to pull their information into your database.

However, it would probably be best if you just hard coded the insert if the radio buttons won't be changing.

盛夏尉蓝 2024-08-26 06:52:08

这取决于您的数据库设计。我建议每个问题和答案都在表中占一行。在 while 循环中,您只需将每个答案/问题对视为一行并对它们使用 INSERT 即可。

It depends on your database design. I would suggest each question and answer to be one row in the table. In the while loop, you just have to treat each answer/question pair as one row and use an INSERT on them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文