如何插入组合数据(组合框和文本字段) [英] How do I insert data combined (combobox and textfield)

查看:105
本文介绍了如何插入组合数据(组合框和文本字段)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计......我对编码很新。



我有这个表格,我试图用混合源对象插入数据文本字段和一个组合框绑定源(我的数据库中的一个表)我可以插入文本字段内容,但我无法插入组合框对象中的内容



Hey Guys... I'm kind of new on codding.

I have this form where i'm trying to insert data with mixed sources objects textfields and one combobox bond source (a table from my DB) i can insert the textfields contents but i cannot insert the content from the combobox object

cmd.Parameters.AddWithValue("@username", SqlDbType.VarChar).Value = userTextBox.Text
cmd.Parameters.AddWithValue("@password", SqlDbType.VarChar).Value = passTextBox.Text
cmd.Parameters.AddWithValue("@regDate", SqlDbType.DateTime).Value = DateTime.Now
cmd.Parameters.AddWithValue("@AuthID", SqlDbType.Int).Value = ComboBoxIDAth.ValueMember





组合框数据插入其Integer类型,因此我要插入的表达式是文本行





The combobox data to insert its Integer type so my expression to insert is a text line

cmd.CommandText = "insert into USERS(NAME,PASSWORD,Initdate,Autorization_ID) values ( @username, @password, @regDate, @AuthID )"
                cmd.ExecuteNonQuery()





我尝试过:



我谷歌它的一些例子,但它没有工作



What I have tried:

I google it some examples but none its worked

推荐答案

你不能以这种方式使用ValueMember,因为它不是ComboBox中的特定项目。请参阅 ComboBox DisplayMember和ValueMember [ ^ ]了解如何使用它,以及如何捕获用户选择的项目。
You cannot use ValueMember in that way as it is not a specific item in the ComboBox. See ComboBox DisplayMember And ValueMember[^] for how to use it, and how to capture the item selected by the user.


这篇关于如何插入组合数据(组合框和文本字段)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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