locked
Show database in window. RRS feed

  • Question

  • Hi,

    I m creating a  database application using CRecordView as the base class.

    Now, i want to show all the records i have in a particular column of a particular table in a list box on my application window.

    How do i do this ?

    The sql query for this would be:
    (if i m not wrong..)
    Select column_name from table_name .
    e.g
    Select book_name from library.

    How do i go about this ??

    Help!!

    Friday, May 8, 2009 1:32 PM

Answers

All replies

  • CRecordView displays one record at a time automagically.  There is no automagic for any other database operations: You will have to learn how to write a loop that steps through the result set one record at a time.  Look up the methods of whatever database/recordset class you are using to do this.

    In the resource editor, add a list box on the CRecordView dialog resource.  Right-click on it and add a CListBox member variable (like m_listboxBookName) with the 'Add Variable' command.  Then as your code loops through the result set call m_listboxBookName.AddString(pset->m_strBookName) for each record. 
    • Marked as answer by Nancy Shao Thursday, May 14, 2009 3:42 AM
    Friday, May 8, 2009 4:55 PM
  • I did the later part which is creating  a dialog box witha  list box in it .
    I also have a menu button which would display the dialog box with the list box which has records in it.

    is there ne link for database tutorial.
    Where i could get examples to learn from.

    To learn mfc i found the Teach VC++ in 21 days very useful.Its a good book for beginners.It also has database examples in it.But they are 2 basic and do not show how to connect to database or how to manipulate the database using client application.

    I have created applications in Java where i have to connect to the database and display them in thr client form.I found ADO.NET very similar
    to Java `s way of connecting to database.(this is just my view ,though i dont know much about ADO.NET).

    So all i want is a good link for a tutorial to learn creating database applications using vc++(mfc and SQL Server 2000).

    Help me out if you know a few websites which could guide me to learn database appliactions.

    Thanking you in advance.



    Friday, May 8, 2009 5:21 PM
  • Hi Vital,

    There are some good artiles about data access with Visual C++, see the following links:

    And you can also find a lot of great articles on http://www.codeproject.com  and http://msdn.microsoft.com/en-us/default.aspx websites.

    Hope this helps,
    Nancy






    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Thursday, May 14, 2009 3:43 AM
    Tuesday, May 12, 2009 6:52 AM