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

Discussion in 'ASP .Net' started by niket patel via .NET 247, Sep 21, 2004.

  1. (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, Sep 21, 2004
    #1
    1. Advertising

  2. niket patel via .NET 247

    David Wier Guest

    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" <> wrote in message
    news:uoplhi%...
    > (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>
     
    David Wier, Sep 21, 2004
    #2
    1. Advertising

  3. niket patel via .NET 247

    Marina Guest

    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" <> wrote in message
    news:uoplhi%...
    > (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>
     
    Marina, Sep 21, 2004
    #3
  4. > (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" <> wrote in message
    news:uoplhi#...
    > (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>
     
    Kevin Spencer, Sep 21, 2004
    #4
  5. niket patel via .NET 247

    Phill. W Guest

    "niket patel via .NET 247" <> wrote in message
    news:uoplhi%...
    > 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.
     
    Phill. W, Sep 22, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    2
    Views:
    889
    Matt Getting
    Jul 24, 2003
  2. byrd48
    Replies:
    0
    Views:
    3,605
    byrd48
    Jul 6, 2006
  3. Oodini
    Replies:
    1
    Views:
    1,846
    Keith Thompson
    Sep 27, 2005
  4. Andy B
    Replies:
    2
    Views:
    3,284
    Andy B
    Apr 23, 2008
  5. Knut Krueger
    Replies:
    8
    Views:
    336
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page