Click here to Skip to main content
15,891,431 members
Home / Discussions / C#
   

C#

 
GeneralRe: What Is the code of one hand clapping? Pin
Pete O'Hanlon18-Mar-13 1:54
mvePete O'Hanlon18-Mar-13 1:54 
GeneralRe: What Is the code of one hand clapping? Pin
Marco Bertschi18-Mar-13 3:26
protectorMarco Bertschi18-Mar-13 3:26 
SuggestionRe: code for genetic algorithm Pin
Steve4419-Mar-13 15:04
Steve4419-Mar-13 15:04 
QuestionRunning .exe in windows form but it opens an external window Pin
Sachin k Rajput 17-Mar-13 21:03
Sachin k Rajput 17-Mar-13 21:03 
AnswerRe: Running .exe in windows form but it opens an external window Pin
Richard MacCutchan17-Mar-13 23:54
mveRichard MacCutchan17-Mar-13 23:54 
AnswerRe: Running .exe in windows form but it opens an external window Pin
Eddy Vluggen18-Mar-13 1:32
professionalEddy Vluggen18-Mar-13 1:32 
GeneralRe: Running .exe in windows form but it opens an external window Pin
Sachin k Rajput 18-Mar-13 3:29
Sachin k Rajput 18-Mar-13 3:29 
AnswerRe: Running .exe in windows form but it opens an external window Pin
Hari Om Prakash Sharma18-Mar-13 1:47
Hari Om Prakash Sharma18-Mar-13 1:47 
GeneralRe: Running .exe in windows form but it opens an external window Pin
Pete O'Hanlon18-Mar-13 1:55
mvePete O'Hanlon18-Mar-13 1:55 
GeneralRe: Running .exe in windows form but it opens an external window Pin
dusty_dex18-Mar-13 2:42
dusty_dex18-Mar-13 2:42 
GeneralRe: Running .exe in windows form but it opens an external window Pin
Pete O'Hanlon18-Mar-13 2:44
mvePete O'Hanlon18-Mar-13 2:44 
GeneralRe: Running .exe in windows form but it opens an external window Pin
dusty_dex18-Mar-13 2:55
dusty_dex18-Mar-13 2:55 
GeneralRe: Running .exe in windows form but it opens an external window Pin
Sachin k Rajput 18-Mar-13 3:28
Sachin k Rajput 18-Mar-13 3:28 
GeneralRe: Running .exe in windows form but it opens an external window Pin
dusty_dex18-Mar-13 5:07
dusty_dex18-Mar-13 5:07 
AnswerRe: Running .exe in windows form but it opens an external window Pin
Vasudevan Deepak Kumar18-Mar-13 9:12
Vasudevan Deepak Kumar18-Mar-13 9:12 
Questionwhat is the meaning of this? Syntax error in UPDATE statement. Pin
kruczynski12316-Mar-13 18:43
kruczynski12316-Mar-13 18:43 
AnswerRe: what is the meaning of this? Syntax error in UPDATE statement. Pin
PIEBALDconsult16-Mar-13 19:23
mvePIEBALDconsult16-Mar-13 19:23 
AnswerRe: what is the meaning of this? Syntax error in UPDATE statement. Pin
Richard MacCutchan16-Mar-13 22:11
mveRichard MacCutchan16-Mar-13 22:11 
AnswerRe: what is the meaning of this? Syntax error in UPDATE statement. Pin
OriginalGriff16-Mar-13 22:54
mveOriginalGriff16-Mar-13 22:54 
GeneralRe: what is the meaning of this? Syntax error in UPDATE statement. Pin
PIEBALDconsult17-Mar-13 10:45
mvePIEBALDconsult17-Mar-13 10:45 
AnswerRe: what is the meaning of this? Syntax error in UPDATE statement. Pin
Abhinav S18-Mar-13 6:37
Abhinav S18-Mar-13 6:37 
QuestionConnection between two forms in a project Pin
coolvibhu16-Mar-13 6:18
coolvibhu16-Mar-13 6:18 
AnswerRe: Connection between two forms in a project Pin
NotPolitcallyCorrect16-Mar-13 6:36
NotPolitcallyCorrect16-Mar-13 6:36 
AnswerRe: Connection between two forms in a project Pin
OriginalGriff16-Mar-13 6:40
mveOriginalGriff16-Mar-13 6:40 
QuestionListBox datasource is not updated on first click Pin
zulfakar16-Mar-13 3:24
zulfakar16-Mar-13 3:24 
i create a winform program that load the data from ms access database to my listbox. when i click my item which i want to update on database and datasource on my listbox and click the update button, the item just wont update for the first time clicked but the second does, so everytime i need to modify my data i need to choose my item and click the update button two times. that's is crazy lol..

C#
private void buttonUpdate_Click(object sender, EventArgs e)
    {
        //update the database
        OleDbDataAdapter cmd = new OleDbDataAdapter();
        cmd.UpdateCommand = new OleDbCommand("UPDATE Item SET ITEM = @ITEM, ITEM_DESC = @ITEM_DESC WHERE ID = @ID",GetConnection());
        cmd.UpdateCommand.Parameters.AddWithValue("@ITEM", textBoxITEM.Text);
        cmd.UpdateCommand.Parameters.AddWithValue("@ITEM_DESC", textBoxITEMDESC.Text);
        cmd.UpdateCommand.Parameters.AddWithValue("@ID", Convert.ToInt32(textBoxID.Text));
        cmd.UpdateCommand.ExecuteNonQuery();

        // update the datasource
        _productlist.Clear();
        listBox1.DataSource = null;
        listBox1.Items.Clear();
        Fill();
        listBox1.Update();
    }


basic thing that happen:

1. load data to listbox with databind to textbox
2. click item on my listbox and modify data from textbox
3. click the update button to update database and datasource
4. datasource not update for the first time but database does update
5. repeat no.2
6. repeat no.3
7. datasource updated

what i want:

1. load data to listbox with databind to textbox
2. click item on my listbox and modify data from textbox
3. click the update button to update database and datasource
4. datasource and database updated

how do i fix this bug on my application?? please let me know if i need to be more clear..

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.