Hello.. I have a form that connects to a database called Test. Inside the databa
ID: 3634838 • Letter: H
Question
Hello.. I have a form that connects to a database called Test. Inside the database I have 5 columns named EmployeeID, FirstName, LastName, Extension, Title. The are populated with about 5-6 items such as (e.g. 1 - John - Doe - 1231 - President). The items are being populated to the screen in two ways - first to a listview item where they show in descending order, second - they show when clicked in the listview in text boxes below. So when you click on the listview item for 1 - John - Doe - 1231 - President, The values are then inputted to the appropriate text boxes. My problem is, I have an update button that I need to take the values you change in those textboxes and when you click update, it connect to the database and update the entries. So when I click update on ( 1 - John - Doe - 1231 - President ) and I change the textbox of President to Janitor and I hit refresh, My listview item has changed his entry to say Janitor. Or if I change his lastname to Steven. It will change any of the boxes, all or one at a time.
SO what im really asking is.. What is the statement and procedure to update the entries from textboxes.
1)cmd.CommandText = "Update INTO Employees " & _
"(EmployeeID, FirstName , LastName, Extension, Title)" & _
" VALUES(@EmployeeID, @FirstName, @LastName, @Extension, @Title)"
cmd.Connection = cnn
2) cmd.Parameters.Add("@EmployeeID", SqlDbType.NChar)
cmd.Parameters("@EmployeeID").Value = txtId.Text
cmd.Parameters.Add("@FirstName", SqlDbType.NChar)
cmd.Parameters("@FirstName").Value = txtFirst.Text
cmd.Parameters.Add("@LastName", SqlDbType.NChar)
cmd.Parameters("@LastName").Value = txtLast.Text
cmd.Parameters.Add("@Extension", SqlDbType.NChar)
cmd.Parameters("@Extension").Value = txtExtension.Text
cmd.Parameters.Add("@Title", SqlDbType.NChar)
cmd.Parameters("@Title").Value = txtTitle.Text
intRows = cmd.ExecuteNonQuery ' affected rows returned
------------------------------------------------------------------------------------------------------------------
Explanation / Answer
hope it will help. http://www.eggheadcafe.com/searchform.aspx?search=Cmd
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.