Saturday, March 24, 2012

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

(Type your message here)
hi
im writing a SQL query in ASP.NET and my string was working and all of a sud
den it stopped working...any ideas'
it say.....Operator '&' is not defined for types 'String' and 'System.Web.U
I.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..
--
From: niket patel
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>8X7yxzmDxUKBSGFi3ACDVg==</Id>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" <anonymous@.dotnet247.com> wrote in message
news:uoplhi%23nEHA.3464@.tk2msftngp13.phx.gbl...
> (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..
> --
> From: niket patel
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>8X7yxzmDxUKBSGFi3ACDVg==</Id>
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" <anonymous@.dotnet247.com> wrote in message
news:uoplhi%23nEHA.3464@.tk2msftngp13.phx.gbl...
> (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..
> --
> From: niket patel
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>8X7yxzmDxUKBSGFi3ACDVg==</Id>
> (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" <anonymous@.dotnet247.com> wrote in message
news:uoplhi#nEHA.3464@.tk2msftngp13.phx.gbl...
> (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..
> --
> From: niket patel
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>8X7yxzmDxUKBSGFi3ACDVg==</Id>
"niket patel via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:uoplhi%23nEHA.3464@.tk2msftngp13.phx.gbl...
> 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.

0 comments:

Post a Comment