How to update particular record using update query in SQL Server with

I have the query to retrieve selected record in textbox ./..

How to use this query to update record :

I want when I enter sumit in textbox1 and click submit button then the record with ID 1 will be updated to name sumit///

Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True")
Dim cmdSelect As New System.Data.SqlClient.SqlCommand("SELECT TOP 1 Name FROM Table1 Order by Id DESC", SQLData)
Dim dtrReader As System.Data.SqlClient.SqlDataReader = cmdSelect.ExecuteReader()
If dtrReader.HasRows Then
   While dtrReader.Read()
      TextBox1.Text = dtrReader("Name")
   End While
   Response.Write("No customer found for the supplied ID.")
End If



Build a SqlCommand with a CommmandText like this

UPDATE FOO SET CustomerName = @CustomerName WHERE ID = @ID

then add two parameters to your commmand with values capture from inputs and run it after setting connection and opening it.

Take a look at this page and it will help you through your work done

Need Your Help

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.