Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.Label'.

  • Thread starter niket patel via .NET 247
  • Start date
N

niket patel via .NET 247

(Type your message here)
hi
im writing a SQL query in ASP.NET and my string was working and all of a sudden it stopped working...any ideas??
it say......Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.Label'.


here is the code...

Line 80: dim strSQL as string
Line 81: strSQL = "INSERT INTO [User] ([FirstName], " & _
Line 82: "[LastName], " & _
Line 83: "[Salutation], " & _


falls over on line 80....doesnt like the &


please help..
 
D

David Wier

We're only seeing part of the statement, so it's a little difficult to
tell - -
the basic format should be:
"Insert into [User] (FirstName, Lastname) values (@Fname, @Lname)"

what happens if you remove all the concatenations?

Show us your complete Insert statement


David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com


niket patel via .NET 247 said:
(Type your message here)
hi
im writing a SQL query in ASP.NET and my string was working and all of a
sudden it stopped working...any ideas??
it say......Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.Label'.


here is the code...

Line 80: dim strSQL as string
Line 81: strSQL = "INSERT INTO [User] ([FirstName], " & _
Line 82: "[LastName], " & _
Line 83: "[Salutation], " & _


falls over on line 80....doesnt like the &


please help..
 
M

Marina

Would have been nice if you posted the complete source code.

But it sounds like you are forgot to put a '.Text' after a label variable's
name to retrieve its text value.

niket patel via .NET 247 said:
(Type your message here)
hi
im writing a SQL query in ASP.NET and my string was working and all of a
sudden it stopped working...any ideas??
it say......Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.Label'.


here is the code...

Line 80: dim strSQL as string
Line 81: strSQL = "INSERT INTO [User] ([FirstName], " & _
Line 82: "[LastName], " & _
Line 83: "[Salutation], " & _


falls over on line 80....doesnt like the &


please help..
 
K

Kevin Spencer

(Type your message here)

Mind if I type my message here instead? ;-)

There is nothing wrong with the code you posted. Therefore, the exception is
being caused by some code you did not post. A compiler will make its best
guess as to the location of the error. However, in some circumstances, the
actual error occurs elsewhere, but doesn't raise an exception there because
of the way the code is written. I would look at the code shortly BEFORE the
line the exception occurred at in your case.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

niket patel via .NET 247 said:
(Type your message here)
hi
im writing a SQL query in ASP.NET and my string was working and all of a
sudden it stopped working...any ideas??
it say......Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.Label'.


here is the code...

Line 80: dim strSQL as string
Line 81: strSQL = "INSERT INTO [User] ([FirstName], " & _
Line 82: "[LastName], " & _
Line 83: "[Salutation], " & _


falls over on line 80....doesnt like the &


please help..
 
P

Phill. W

niket patel via .NET 247 said:
Operator '&' is not defined for types 'String' and
'System.Web.UI.WebControls.Label'.

"Default Properties" are Dead and Gone, so you can't code

sValue = "This" & lblThat

any more. You /must/ specify the .Text property for the Label, as in

sValue = "This" & lblThat.Text

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top