The problem is it works updating the records but all records will gonna update... i want to update the selected records only.. I use Listview~!

example column table:

                      Processor
                      Pentium(R)
                      Intel(R)
                      Dual CPU

when I edit the Intel(R) into VGAgraphics, the Pentium(R) and Dual CPU will also change into VGAgraphics when i click update..

Please help me to solve this~~!

Here's my code:

Module1.connect()
Dim ValueToUpdate1 As String

ValueToUpdate1 = TextBox2.Text.ToString()

sqlcmd = New SqlCommand("UPDATE table1 SET [Processor]=@Processor", sqlconn)

sqlcmd.Parameters.AddWithValue("@Processor", ValueToUpdate1)
    sqlcmd.ExecuteNonQuery()
    MsgbBox("Updated Successfully")
        sqlconn.Close()

If you want to update a single record you need to add a where clause to your sql statement.

sqlcmd = New SqlCommand("UPDATE table1 SET [Processor]=@Processor WHERE id=@id", sqlconn)

You just need to get the unique identifier for the row you wish to update in your database table.

Hope this helps!

I try this codes, its running but its not changing the value that i type

Dim id As Integer
id = Integer.MaxValue
sqlcmd = New SqlCommand("UPDATE table1 SET [Processor]=@Processor WHERE id=@id", sqlconn)
sqlcmd.Parameters.AddWithValue("@id", id)

help me to improve this~!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.