Results 1 to 3 of 3

Thread: [RESOLVED] SQL Server Text field to text box

  1. #1

    Thread Starter
    Lively Member homer13j's Avatar
    Join Date
    Nov 2003
    Location
    Where the dirt bikes and ATVs play
    Posts
    80

    Resolved [RESOLVED] SQL Server Text field to text box

    I have an old database that still contains depreciated Text fields. I need to pull from these fields and display the results. You would think this should be easy...

    First my select statement caused a problem:

    Code:
    SELECT DISTINCT ..., CustomerInstructions, ... FROM Orders
    where CustomerInstructions is a Text field.

    The error I get: "The text data type cannot be selected as DISTINCT because it is not comparable." A quick search shows I can cast the text field as a varchar(max).

    Code:
    SELECT DISTINCT ..., CAST(CustomerInstructions AS VARCHAR(MAX)), ... FROM Orders
    Now I get an error while trying to load the instructions into a text box: "Specified argument was out of the range of valid values. Parameter name: index"

    Not sure what the problem is here. I have text and a text box. What's with the "out of range" crap?
    "Bones heal. Chicks dig scars. Pain is temporary. Glory is forever." - Robert Craig "Evel" Knievel
    “Leave me alone, I know what I’m doing.” - Kimi Raikkonen

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: SQL Server Text field to text box

    What does the code look like when loading it into the textbox? I just noticed that after you cast it, you didn't give the column a name... so if you're trying to reference it by the name CustomerInstrucitons... it doesn't exist... thus it's out of range... alias the field as CustomerInstructions and it should work again.


    -tg
    Last edited by techgnome; Apr 11th, 2014 at 07:40 PM.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Lively Member homer13j's Avatar
    Join Date
    Nov 2003
    Location
    Where the dirt bikes and ATVs play
    Posts
    80

    Re: SQL Server Text field to text box

    This whole project was written in 2003 and I'm not having much fun fixing it...

    I ended up solving my problems by dropping the DISTINCT since duplicate records aren't a problem. Not sure why it was added to begin with.
    "Bones heal. Chicks dig scars. Pain is temporary. Glory is forever." - Robert Craig "Evel" Knievel
    “Leave me alone, I know what I’m doing.” - Kimi Raikkonen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width