0

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()

Edited by sonyeo: x-type

2
Contributors
2
Replies
16
Views
4 Years
Discussion Span
Last Post by sonyeo
0

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!

0

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~!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.