我需要使用 while 循环将 10 个单选按钮值放入 vb.net 的插入语句中
我有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是新手,因此当您更有信心时这可能会对您有所帮助,但您可以做的一件事是在代码隐藏中创建一个单选按钮数组。然后,您可以遍历单选按钮数组,将其信息提取到数据库中。
但是,如果单选按钮不会更改,那么最好只是对插入进行硬编码。
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.
这取决于您的数据库设计。我建议每个问题和答案都在表中占一行。在 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.