user1342164
user1342164

Reputation: 1454

Operator '&' is not defined for string "INSERT INTO

I am trying to insert "NameofProduct" into my database and I am getting an error Operator '&' is not defined for string "INSERT INTO

The insert statement only fails when the line below is used to populate "NameofProduct" Can anyone find anything wrong with this?

NameofProduct = Session("Product1").ToString &
                "," &
                Session("Product2").ToString.Replace("Select....", "") & 
                "," &
                Session("Product3").ToString &
                "," &
                Session("Product4").ToString &
                "," &
                Session("ProductManual").ToString

Upvotes: 0

Views: 1195

Answers (1)

Justin R.
Justin R.

Reputation: 24091

Can you confirm that all of the Session members (e.g., Session("ProductManual")) have values at all times?

In any case, you're better off going with a parameterized query, rather than building the query string this way. This will be less error prone, protect you from SQL injections, and is faster (as the query won't need to be prepared each time). Check out this page on MSDN.

Upvotes: 1

Related Questions