Reputation: 403
I have a SQL string in Asp.net web page, with vb code behind.
It was working fine before but for unknown reason I start now getting the following error:
Error: Sys.WebForms.PageRequestManagerServerErrorException: Operator '&' is not defined for string "UPDATE db
.usersdata
SET `SH" and type 'TextBox'.
UPDATE: SH is a string ('SAVE' or 'HIDE')
UPDATE: I am using MySQL database on the background.
Protected Sub savehide_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim SQLstring As String = ""
Dim SH As String
SH = saveorhide.SelectedItem.Value
' the following line is where the error occurs
SQLstring = "UPDATE `db`.`usersdata` SET `SH`='" & SH & "' WHERE `PIC` = '" & Session("UserId") & "'"
Session("SH") = SH
SQLNonQuery_mysql(SQLstring)
CLEARALL()
displaydata()
End Sub
I have spent hours but I cannot find the reason for this, specially when before it was working fine. This code runs when a dropdownlist field is changed. The thing it also started to happen to other dropdownlist and SQL string creation code...So it is failing in various VB places now (as I said before it wasn't) I am wondering if there is a bug or some weird reason why this error is coming out now (and not before) and what would be the solution.
Upvotes: 0
Views: 46
Reputation: 6979
According to the error message, either SH
is a TextBox or Session("UserId")
is a TextBox.
Since you already showed the declaration of SH
, the only suspect remaining is the Session("UserId")
.
Can you show how you are setting the Session("UserId")
value?
My best guess is that you are doing this:
Session("UserId") = TextBox1
you should change it to:
Session("UserId") = TextBox1.Text
(replace TextBox1
with name of your TextBox)
Upvotes: 2