CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2017
    Posts
    3

    Finding size of a database field

    I am writing in C++ using Visual Studio 2015. The program question takes data from a user and stores parts of his input as text fields in an Access database. I want to know the capacity of the database field: say it’s TEXT(75), I will warn the user if the data submitted for stage in that field exceeds 75 characters. I have a class generated from the table, is there any way, if I open either the table class, or the underlying database, I can use a C++ function on one of the classes to tell me the size. As if I were doing:
    long max=database(“databasename”).table(“tablename”)
    .field(“stringfieldname”).GetMaxSize();

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Finding size of a database field

    What are you using to access the database? ADO, MFC ODBC classes, something else?
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2017
    Posts
    3

    Re: Finding size of a database field

    MFC OBDC classes

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Finding size of a database field

    Then have a look at the CRecordset::GetODBCFieldInfo method.
    Victor Nijegorodov

  5. #5
    Join Date
    Feb 2017
    Posts
    3

    Re: Finding size of a database field

    Thank you. Problem solved!

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Finding size of a database field

    You are welcome!
    You can now could mark the thread as "resolved" and, perhaps, share the solution!
    Victor Nijegorodov

Tags for this Thread

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