Results 1 to 9 of 9

Thread: [RESOLVED] Conversion from type 'InternalField' to type 'String' is not valid.

  1. #1

    Thread Starter
    Addicted Member raptormanad's Avatar
    Join Date
    Oct 2008
    Posts
    224

    Resolved [RESOLVED] Conversion from type 'InternalField' to type 'String' is not valid.

    We get this error:

    Conversion from type 'InternalField' to type 'String' is not valid.

    When we get to this in our code:

    Code:
    Dim fname2 = fname
            args.Graphics.DrawString(fname2, New Font("arial", 8), Brushes.Black, 5, 5)
    fname is a nvarchar variable from a recordset. It's just a name. Any ideas?

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Conversion from type 'InternalField' to type 'String' is not valid.

    What the purpose behind that fname2 variable?
    What happens when you do this?
    Code:
            'Get rid og fname2 and use fname directly
            args.Graphics.DrawString(fname, New Font("arial", 8), Brushes.Black, 5, 5)
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Addicted Member raptormanad's Avatar
    Join Date
    Oct 2008
    Posts
    224

    Re: Conversion from type 'InternalField' to type 'String' is not valid.

    Same error.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Conversion from type 'InternalField' to type 'String' is not valid.

    It should be. That first argument needs to be a string. fname isn't a string. Try fname.ToString and see what you get.
    My usual boring signature: Nothing

  5. #5
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Conversion from type 'InternalField' to type 'String' is not valid.

    How do you assign the value to fname? Have you tried using the .ToString() method of the object?

  6. #6

    Thread Starter
    Addicted Member raptormanad's Avatar
    Join Date
    Oct 2008
    Posts
    224

    Re: Conversion from type 'InternalField' to type 'String' is not valid.

    we tried tostring. now we get this when we print...

    ADODB.InternalField

    We need to display the variable data, not whatever this.

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Conversion from type 'InternalField' to type 'String' is not valid.

    Yeah, what you got there is the name of the type of fname. Obviously, it is NOT a string. Therefore, -0 asked the right question: How are you setting fname, as it is not what you think it is?
    My usual boring signature: Nothing

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Conversion from type 'InternalField' to type 'String' is not valid.

    w/o knowing what fname is dimemd as, this is a stab inthe dark, but, it could be that fname is a field.... not the field's value... this is also an example of why Option Strict and Option Explicit are a good idea.

    -tg

    EDIT - dang, that's what I get for letting it sit before replying... additionaly, is there a reason you're using ADODB and not ADO.NET?
    * 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??? *

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Conversion from type 'InternalField' to type 'String' is not valid.

    Oh yeah: It is possible that fname.Value.ToString will work, but that's just a shot in the dark, at this point.

    EDIT: WOOHOO! Not only did I match TG's guess, I even came close to using his exact metaphor.
    My usual boring signature: Nothing

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