Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Form Fields

Status
Not open for further replies.
Joined
Mar 14, 2002
Messages
711
Location
US
I am trying to update some form fields but each time I click the submit button it comes back with an error:

Syntax error near keyword "where"...

This is the code I have for the update statement:

Sub Button_Update(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim strUpdate As String
Dim strStatus = Status.SelectedItem.Value
Dim strLongDescription = DescrTxt.Text
Dim strUserName = UserTxt.Text

strUpdate = "UPDATE Kaizen SET Status = '" & strStatus & "', LongDescription = '" & strLongDescription & "', where Date = '" & Session("Date") & "' and KaizenID = '" & Session("ID") & "'"



'If Len(Trim(strSafetyAnalysis)) > 0 Then
'strSafetyAnalysis = Replace(strSafetyAnalysis, "'", "''")
'End If


Const StrConnString As String = ""

Dim objConn2 As New SqlConnection(StrConnString)

objConn2.Open()

Dim cmdUpdate As SqlCommand

cmdUpdate = New SqlCommand(strUpdate, objConn2)

cmdUpdate.ExecuteNonQuery()

objConn2.Close()


End Sub


End Class


I am calling the session variables earlier in another sub routine, is it possible they "expired"?

Thanks in advance,
 
Nevermind, missed the "extra" comma before the WHERE....


sometimes a blind man can see too ;-)
 
You should really use parameters for this function as you are leaving yourself open to an SQL Injection attack.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Yeah I know, I have been bad about that, mostly because it is all internal code (Intranet), but still i should change...

Thanks ca8msm!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top