是否可以在选择的组合框项目的基础上生成数据库中的值? [英] Is it possible for to generate a value in a database base on the combobox item selected?

查看:51
本文介绍了是否可以在选择的组合框项目的基础上生成数据库中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if (cbProductDescription.SelectedItem.ToString() == "Prepaid - 300")
                {
                    command.Parameters.AddWithValue("@Price", 7);
                }

推荐答案

如果我正确理解了你应该做的问题,你可以枚举你的组合框中的选项或获取它们来自数据库并包含已在数据库中生成的键值。现在,此键值将用于您的其他命令参数。如果这是表格,请使用 ValueMember [ ^ ]属性,用于将键值分配给组合框项目。
If I understood the question correctly what you should do is either enumerate the choices in you combo box or fetch them from the database and include the key value already generated in the database. Now this key value would be used in your other command parameters. If this is forms for example, use the ValueMember[^] property to assign the key value to a combo box item.


这篇关于是否可以在选择的组合框项目的基础上生成数据库中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆