Start New Discussion Reply to this Discussion Update one column with multiple values from multiple text box
hi can someone please help me in updating one column in a table but you will be using three values from a textbox..
it was like this.
tablebook
column in tablebook is quantity
i need to update a book quantity using the value from textbox1. but
wat if i have a value from textbox2 and textbox3
i need to update textbox1,textbox2,textbox3 values into book quantity where it has different bookname
sample of my coding
If TextBox1.Text <> "" And TextBox2.Text <> "" And TextBox4.Text <> "" Then
SqlCon.Open()
sqlCommand.Connection = SqlCon
sqlCommand.CommandText = "UPDATE books SET quantity = " & qt1.Text - 1 & " WHERE book_ID = '" & TextBox1.Text & "'"
sqlCommand.ExecuteNonQuery()
SqlCon.Close()
update_quantity_borrow()
SqlCon.Open()
sqlCommand.CommandText = "UPDATE books SET quantity = " & q2.Text - 1 & " WHERE book_ID = '" & TextBox2.Text & "'"
sqlCommand.ExecuteNonQuery()
SqlCon.Close()
update_quantity_borrow()
SqlCon.Open()
sqlCommand.CommandText = "UPDATE books SET quantity = " & q3.Text - 1 & " WHERE book_ID = '" & TextBox4.Text & "'"
sqlCommand.ExecuteNonQuery()
SqlCon.Close()
update_quantity_borrow()
End If
annquin
Newbie Poster
4 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
can you please explain little bit , ?what you want to do ? may be we can give to better solution .
Regards
M.Waqas Aslam
Master Poster
743 posts since Aug 2011
Reputation Points: 50
Solved Threads: 120
Skill Endorsements: 2
Maybe I'm reading this wrong, but you'll have multiple rows, each with a book and a possible Quantity. you want the user to hit Update once and it will update each Row with the Quantity if it exists?
If that's correct, why not just do a Loop through the Rows, for each Row, if txtQty > 0 then Update based on current RowID ?
Also, they way you are performing your SQL Querys is a huge no-no, it's begging for SQL injection and a Hack!
TimCadieux
Newbie Poster
15 posts since Aug 2012
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0657 seconds
using 2.68MB