Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-08 : 10:03:56
|
I'm trying to do a Sql Update from my asp.net page, but it does not seem to be updating. I know that the query works in Query Analyzer but it does not work in my aspx page. Can anyone see what's wrong or have any suggestions?I have 2 update query in the same sub, would that matter? Here's how I have it set.Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs)Dim connectionString As String Dim user As String = System.Configuration.ConfigurationSettings. _ AppSettings("mappedname") Dim pass As String = System.Configuration.ConfigurationSettings. _ AppSettings("mappedkey") connectionString = "data source=sql-server; Database=" & Session("AuthDB") connectionString &= ";user id=" & user connectionString &= ";password=" & passDim strConnect As String = connectionStringDim strUpdate As String = "UPDATE quote " _& "SET username ='" & txtName.Text & "', " _& "phone = '" & txtPhone.Text & "', " _& "department = '" & txtDepartment.Text & "', " _& "WHERE id = '" &strID & "'"Dim myConnection As New SqlConnection(strConnect)Dim myCommand As New SqlCommand(strUpdate, myConnection)myConnection.Open()myCommand.ExecuteNonQuery()myConnection.Close()If strDatabase = "ACCT" ThenDim strSpecUpdate As String = "UPDATE quote_binary " _& SET bit = '" & txtSpecs.Text & "', " _& "WHERE quote_id = '" & strID & "'"Dim myConnection2 As New SqlConnection(strConnect)Dim myCommand2 As New SqlCommand(strSpecUpdate, myConnection2)myConnection2.Open()myCommand2.ExecuteNonQuery()myConnection2.Close()End IfBindData()End Sub |
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-03-08 : 10:34:51
|
Got it working now. I felt so stupid hehehe. If strDatabase = "ACCT" ThenDim strSpecUpdate As String = "UPDATE quote_binary " _& SET bit = '" & txtSpecs.Text & "', " _& "WHERE quote_id = '" & strID & "'"Removed the ',' next to txtSpecs.Text and working. I wasn't paying attention close enough to the debug until now. |
 |
|
jhermiz
3564 Posts |
Posted - 2005-03-08 : 11:36:56
|
may want to put this in a stored procedure.Jon Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]Imperfection living for perfection -- [url]http://jhermiz.blogspot.com/[/url] |
 |
|
|
|
|