简体   繁体   中英

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. And I use a dataset.xsd file and connection string to communicate between client and the online database.

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. 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.")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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