Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.Label'.

Reply
Thread Tools

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

 
 
niket patel via .NET 247
Guest
Posts: n/a
 
      09-21-2004
(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>
 
Reply With Quote
 
 
 
 
David Wier
Guest
Posts: n/a
 
      09-21-2004
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" <(E-Mail Removed)> wrote in message
news:uoplhi%(E-Mail Removed)...
> (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>



 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      09-21-2004
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" <(E-Mail Removed)> wrote in message
news:uoplhi%(E-Mail Removed)...
> (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>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      09-21-2004
> (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" <(E-Mail Removed)> wrote in message
news:uoplhi#(E-Mail Removed)...
> (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>



 
Reply With Quote
 
Phill. W
Guest
Posts: n/a
 
      09-22-2004
"niket patel via .NET 247" <(E-Mail Removed)> wrote in message
news:uoplhi%(E-Mail Removed)...
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User-defined exception: "global name 'TestRunError' is not defined" jmike@alum.mit.edu Python 1 07-10-2008 12:37 PM
user defined conversion operator or operator overloading? hurcan solter C++ 3 08-29-2007 07:39 PM
short form for (defined $x and defined $y and ... )? Markus Dehmann Perl Misc 19 03-27-2006 08:32 AM
Overloading Operators for User-Defined Types (NOT Classes!) Randy C++ 27 01-05-2006 05:03 PM
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) Oodini C Programming 1 09-27-2005 07:58 PM



Advertisments