VC++ 6 and database question

This is a discussion on VC++ 6 and database question within the Windows Programming forums, part of the Platform Specific Boards category; I can display a single record ( name - address - blah blah) and edit the record. I want to ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    7

    VC++ 6 and database question

    I can display a single record ( name - address - blah blah) and edit the record.

    I want to display multiple records. I have been looking for examples and have been unable to find any code that I can look at that would display multiple records at one time rather than a single record.

    any pointers? Thanks much

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,752
    An array of records and a for loop.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    Well, yes, that is what will need to be done to accomplish it, but that doens't help much.

    I have a database of over 12000 records. I would like to search for a zip code and display all the records that have that zip code. I would like them to all display on the screen at once rather than one by one. I do not know how many results I will get. I am not that familiar with ActiveX plugins for VC++6. If anyone knows of some examples of code that I could look at that would accomplish this, that would be the best help.

    Thanks again

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Is the database a standalone database like MySQL or Oracle, or is it one of your own creation?

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    It is a MySQL database.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Then why not use the SQL to chose the records for you?

    SELECT * FROM MyTable WHERE zip='21547'

    Or whatever

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,752
    Ah, now all is clear
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    I know how to select the records. I know how to view a single record. I can write an app that will step thru each record one by one.

    What I would like to do is view more than one record at one time. I do not know how to accomplish that.

  9. #9
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Yor not making enough sense.

    Do you mean to show the records via a view?

  10. #10
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    Yes, I think I found that DBGrid may be helpful in this. I am not familiar with DBGrid and I am looking for more information on it. any advice ?

    thanks much for your patience and all that jazz.

  11. #11
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    OK, now we are getting there.

    Are you using MFC (if not, then using ActiveX controls is a very painful experience)?

    How are you addressing the MySQL Database? Naitive C Api, ADO?

    What is the exact control you wish to use? This is important because there are loads of them and they all work differently. Also, when chosing the component, make sure that it is distributable and doesnt need a certain app installed and a licenece to work on another machine.

    Personally I dont like useing these grid-controls. I prefer using a CListCtrl in MFC and adding the details myself.

  12. #12
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    Since I have not written the app yet, I am open to any suggestions. As you can tell, I am new to VC++ programming. I have been reading alot of tutorials, but I have not seen any that do or come close to what I would like to do.

    I am using the MFC. The database is in MySQL(4.1)with an ODBC connector.

  13. #13
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Hi,

    try looking at the API functions on MySQL's website for starting points with basic MySQL usage from within programs. I use the C API as it is easy, but you should write your own version of mysql_query() using va_arg() and such (as long as it can't be exploited ), you might want to look at mysql++ if using C++

    Maybe I haven't woken up to using C++ yet
    - Daniel Wallace

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21