Hack Forums
[.NET] Updating listview data overwrites all the data - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Updating listview data overwrites all the data (/showthread.php?tid=3304979)



Updating listview data overwrites all the data - Snoepie1012 - Mar 5, 2013

Sup guys

I made a application that would retrieve information from my Mysql database and put it in a Listview (Under categories such as name, email, ...)
I made it so when you double click a data line in the Listview a new form would open with textboxes with the data in it so you could edit it.

However when you edit some data and then click the 'Save' button all the listview items are changed (Not just the line you double clicked but also the data under it)


My code to change the listview item:

Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As MySqlConnection = New MySqlConnection("Data Source=localhost;Database=fca;User ID=root;Password=;")
        strsql = "Update informatie set Naam = '" & TextBox1.Text & "', Bijvoegsel = '" & TextBox2.Text & "', Achternaam = '" & TextBox3.Text & "'"
        Dim da As New MySqlDataAdapter(strsql, con)
        da.Fill(ds)
        Me.Hide()

        Form2.list()
    End Sub

Hope someone can help me! If you need more information just ask.

Thanks!


* - Occulta - Mar 5, 2013

Just load all the information into a listview (without MySqlAdapter) and then use SqlQueries to update, save, delete, add, etc. It's so much easier.


* - Snoepie1012 - Mar 5, 2013

(Mar 5, 2013 10:52 AM)Occulta Wrote:  Just load all the information into a listview (without MySqlAdapter) and then use SqlQueries to update, save, delete, add, etc. It's so much easier.

Yes I was already thinking about doing that, but how would I edit that single line and not everything :/


* - Occulta - Mar 5, 2013

(Mar 5, 2013 11:04 AM)Snoepie1012 Wrote:  Yes I was already thinking about doing that, but how would I edit that single line and not everything :/

MySQL Queries.. Like I said.

Code
UPDATE WHERE

http://www.w3schools.com/sql/sql_update.asp