problem with db table

This is a discussion on problem with db table within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I've asked a few questions now in reference to db programing, my newest problem in my learning curve, is ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    164

    problem with db table

    Hi, I've asked a few questions now in reference to db programing,

    my newest problem in my learning curve, is referencing a db table. In my code I can open the db and reference a table just fine, but when I alter my code and add variables to store data from another table within the same database, and I can not get the results.

    I know the db is open, but it simply does not reference the info in the table.

    Has anyone had experience with table conflicts like this, could I have set the table up wrong, or ??? Could this be general problem?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    What are you using ODBC ADO MFC ect?

    Are you using a record set class derived from a specific table in the database?

    Try closing the DB, opening it again with a new table name.


    Post the code for the open and close. Here is a simple example of MFC + ODBC

    Code:
    //strings defined elsewhere
    //DB_TABLE_TITLE the title/name of the table
    //DB_DNS_NAME the Data source name installed in the PC, coresponding to the database
    
    CDatabase	DB;
    //open  the DB
    DB.OpenEx(DB_DNS_NAME,CDatabase::noOdbcDialog);
    //init the record set with the open DB
    CRecordset  Table(&DB);
    //now open the specific table
    Table.Open(AFX_DB_USE_DEFAULT_TYPE,DB_TABLE_TITLE);
    //close the record set
    if(Table.IsOpen())
    	Table.Close();
    //and DB
    if(DB.IsOpen())
    	DB.Close();
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    164
    Thanks Novacain, sorry for the late response, been out of town! I will try the open and close of the db with different table name, thanks also for the code sample, you do things much more effeciently, I am new to this style of programing and appreciate the help, will post my findings.

    Thanks again

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    164
    Oh and I am using ODBC, I had alot of trouble getting my open calls to work, so I used a class created on codeproject.com, curious though, the calls and open messages that you used in the sample code, is that just using the CRecordset:: from afxdb.h?

    I want to standardize my code, so I am learning proper methods finding books local to me on the subject have been few and far between.

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    >>the calls and open messages that you used in the sample code, is that just using the CRecordset

    Yes.

    You can derive a class specific to a/each table from a database.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    164
    Hey that db close and reopen worked like a charm, thanks for the insight, your life saver. I still have bruises from banging my head on my desk!

    If you don't mind, I may have some questions with the CRecordset:: I really enjoy this type of programing, the real time data is great, but learning curve is substantial. Thanks again!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ASP.NET question (looping inside a table)
    By Rainbowinblack in forum C# Programming
    Replies: 0
    Last Post: 03-06-2008, 03:10 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Big Problem With Passing an Matrix to Main Function
    By Maragato in forum C Programming
    Replies: 4
    Last Post: 06-15-2004, 12:06 AM
  4. progarm doesnt compile
    By kashifk in forum Linux Programming
    Replies: 2
    Last Post: 10-25-2003, 06:54 PM
  5. Problem with Hash Table Linear Probing
    By kirby1024 in forum C Programming
    Replies: 5
    Last Post: 10-23-2002, 07:03 AM

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