简体   繁体   English

未绑定的组合框与数据库通信

[英]Unbound Combobox communicate with the database

I have a table contain following columns: 我有一个包含以下各列的表:

*Id(int) *Name(nchar) *Type(nchar) *Description(nchar) The table is in online database. *Id(int) *Name(nchar) *Type(nchar) *Description(nchar)该表位于在线数据库中。 And I use a dataset.xsd file and connection string to communicate between client and the online database. 我使用dataset.xsd文件和连接字符串在客户端和在线数据库之间进行通信。

I have one Combobox with three item in it (Type1, Type2, Type2), I want to fill the database Table column "Type" base on the user selection result of Combobox. 我有一个Combobox,其中包含三个项(Type1,Type2,Type2),我想根据Combobox的用户选择结果来填充数据库表“ Type”列。 I don't know how to do that. 我不知道该怎么做。 在此处输入图片说明

Here is some of the method I use: 这是我使用的一些方法:

`ADataSet = New DataSet
ATableAdapter = New DataSetTableAdapters.TableTableAdapter
ATableAdapter.Fill(ADataSet.Table) '(when loading)
ATableAdapter.Update(ADataSet.Table) '(when Editing or Adding)
ABindingSource = New BindingSource
`

Give this a try and give me some feedback 试试看,给我一些反馈

    ATableAdapter.Fill(ADataSet,"Your_Table")       
    Dim dsNewRow As DataRow
    dsNewRow = ADataSet.Tables("Your_Table").NewRow()    
    dsNewRow.Item(0) = ID
    dsNewRow.Item(1) = Name
    dsNewRow.Item(2) = Type
    dsNewRow.Item(3) = Desc
    ADataSet.Tables("Your_Table").Rows.Add(dsNewRow)
    ATableAdapter.Update(ADataSet,"Your_Table")
    MsgBox(ID & " has successfully been added to the system.")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM