Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

I have a listview filled with a table from database with:

Private Sub FillList ()

....

....

SQL = "SELECT * FROM Voti"

dataSetVoti = New DataSet()

mioDataAdapter = New OdbcDataAdapter(SQL, dbConn)

mioDataAdapter.Fill(dataSetVoti, "Voti")

For Each resDataRow In dataSetVoti.Tables("Voti").Rows

lstItem = ListView1.Items.Add(resDataRow("Voti"))

.....

Next

.....

.....

End Sub

 

Then if I Update the table with:

 

Dim cmdVoti As OdbcCommand

Dim dbWriter As OdbcDataReader

SQL = "UPDATE Voti SET Voti = " & votiToAdd & " WHERE Codice = " & CLng(lvi.SubItems(4).Text)

cmdVoti = New OdbcCommand(SQL, dbAccr)

dbWriter = cmdVoti.ExecuteReader

dbWriter.Close()

 

and then call FillList ()

the table in database is updated but I do not see any changes in listview until I perform another Update and see the changes for the previous record updated and not for the last one or I have to close the form and re-open it to see the updated records.

Which is the mistake?

Thank you in advance.

Posted

Thank you PlausiblyDamp.

Unfortunely I Can't understand your replay probably due to my english. I'm italian. Could you please expose your replay in a different way, possibly with one or two lines of code?

Thank you.

  • Administrators
Posted

Nothing to do with your English - more to me not reading the question properly ;)

 

When you are doing the update try

Dim cmdVoti As OdbcCommand
SQL = "UPDATE Voti SET Voti = " & votiToAdd & " WHERE Codice = " & CLng(lvi.SubItems(4).Text)
cmdVoti = New OdbcCommand(SQL, dbAccr)
cmdVoti.ExecuteNonQuery()

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

I've tried the code you post but nothing happened.

The problem still continue.

Even if I've solved the problem writing new value directly into the listview to show to user the change, I'd like to solve the problem in smarter way.

Posted

kromax:

 

You have to do 2 updates: Update your SQL database, then also update your local copy of the dataset.

 

I am no expert with databases, so this may be worded incorrectly; however, I had this same problem for many days. The solution was to update the SQL table; if that was successful, update my local copy of the data in the dataset.

 

I hope this is easy to understand in Itally.

 

If my logic is flawed, maybe PlausiblyDamp will step in to explain it better.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...