CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001
    Posts
    9

    Database Variable Problems

    i need to assign variables from a recordset called from an SQL statement but i can't figure out how to change the Field Name bit to a variable .... i've tried all sorts of bracket combinations, etc but to no avail. is this possible at all?

    EG:

    VarToBeAssigned = RstRecordSet![NeedToHaveVarInHere]



  2. #2
    Join Date
    Aug 2000
    Location
    England
    Posts
    185

    Re: Database Variable Problems

    Try:

    VarToBeAssigned = RstRecordSet![<FIELD_NAME in database>]



  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Database Variable Problems

    are you looking for this?
    dim varFieldName as string
    varFieldName= "A_field_name"
    varToBeAssigned= rsRecordset(varFieldName).value

    Warning: the recordset maybe a null value, so
    varToBeAssigned better be variant!

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Aug 2001
    Posts
    9

    Re: Database Variable Problems

    thanks a lot ... it was the .value bit that i was missing to sort that out


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

Featured