I'm making windowsform in visualstudio2017.
https://nonbiri-dotnet.blogspot.com/2016/12/blog-post_29.html
The data stored in the database is stored by column specification with reference to.
A program that stores data in the database when the button is pressed
private void button1_Click (object sender, EventArgs e)
{
cn.ConnectionString = cnstr;
cn.Open ();
cmd.Connection = cn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO [dbo]. [TEXT] VALUES (" +
"N '" + textBox2.Text + "')";
MessageBox.Show ("Saved in database");
rd = cmd.ExecuteReader ();
rd.Close ();
cn.Close ();
textBox2.Clear ();
}
Made.
However, the data stored by pressing the button is not stored in combBox.
However, when windowsform is closed and launched, the stored data is stored in combBox.
So please tell me how to add data to combBox when you insert by pressing the button without closing and opening windowsform.
// TODO: This line of code reads data into the 'database1DataSet.TEXT' table.
this.TEXTTableAdapter.Fill (this.database1DataSet.TEXT);
>>Products
Windows Form
>>Search
c # combobox datasource I checked it with the update, but it was not found.
>>Development environment
Visual Sutaudio2017, C # ,. NET Framework4.7, SQL Server Express2017, Windows10
-
Answer # 1
Related articles
- c # - [unity] i can't update and get custom properties in photon
- c # - i want to update the value
- c # - how to update sharepoint update date
- if you update the database value with update in c # and search with select, it will be ???
- add update process in c # save button
- c # - i want to update and delete the data output by binding
- c # - fixed bool switch does not work properly in fixed update of unity
- c # - [unity] coroutine processing and processing in update function are batting
- c # - update characters in postgresql
- about void update function in c #
- c # - update process using entity framework does not work
- c # - about unity update method
- [c #] execute tasks with different types as return values in parallel, and calculate by combining the results
- c # - merge statement that can be executed by ssms causes an error in executenonquery
- [c # net] when recognizing a double click in datagridview, it cannot be recognized unless you click in the view once first
- c # - about wpf x button control
- c # - i don't know how to learn net framework
- c # - mstest library file name is too long and build error
- i want itextsharp to display table borders twice (c #)
- c # - what to do about the error message "index is out of array bounds"
- c # - i want to put a thread to sleep for a long time
- i want to pass an argument to mainwindow () and execute it [wpf net framework c #]
I imagine you are binding a DataTable named TEXT to a ComboBox, but if that's the case, you won't see the item you added to the ComboBox because the INSERT result is not reflected in the TEXT.
What happens if I fill and bind again at the end of button1_Click? Note that if you do not clear the contents of TEXT before filling, the item may be double.