Archived

This topic is now archived and is closed to further replies.

I desperately need advise... C++ and Databases?

This topic is 4973 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First of all thank you for takeing the time to look! I have to do a large assignment on databases with C++. I''m kind of lost here, as I don''t even know how C++ handles databases. What I need is a link or just a point in the right direction so I can start doing research myself, I''ve got Ivor Norton''s book called "Beginning C++" it''s a big red book on around 1000 pages. The cloests I could come in that is file and stream handeling - is this what I need or is there some way to work a specific database where I can create records etc.? I''m sorry for being so vague, it''s the best I can do though... I hope there is someone out there who can give me a hint or two? Thanks! Yip

Share this post


Link to post
Share on other sites
Short answer: C++ doesn''t handle databases. Look into MySQL or something the like and download their C++ libraries for database programming. Alternately use a compiler/IDE suite that comes with database functionality (I believe Borland C++ Builder has Oracle access available).

The file streams and stuff could be what you''re looking for if you plan on making your own database format, but I highly doubt that''s what you want. It''s not only tedious and error-prone but not at all worth the effort.

Just wondering, you say this is an assignment; so it''s very likely for school (if it''s for work, Gods help you...). Have you considered asking the instructor what you''re supposed to do? Because given how vaguely you described it, what came right off the top of my head here is that this is an assignment for a class in which you attend only one in five lectures.

If that''s not the case and your prof is whacked so bad that they''re giving you assignments like this ("make a program with databases with C++") without explaining anything, then you really need to talk to them.

Otherwise, without further clarification, nobody can help you much more.

-Auron

Share this post


Link to post
Share on other sites
Thank you for your reply Auron!

No thank god it''s not for work, it''s for school... the problem is I''m not quite sure the "instructor" knows what he is doing

The assignment is something we have to study for ourselves, it''s "above" what we are being teached. Basically what he wanted was being able to create and delete records, fill in and change the contents of the records.

"The file streams and stuff could be what you''re looking for if you plan on making your own database format, but I highly doubt that''s what you want. It''s not only tedious and error-prone but not at all worth the effort."

I''ve got around a month and a few weeks to complete this assignment, is that too little time to be able to get a decent grasp of this? And would it have the function that I stated above?

Thanks again, I know I''m being very vague here... but you''d just have to know the "teacher" to understand why I can''t be more clear (as I don''t know anything on the subject yet myself) he said he had teached C++ before though.

Yip

Share this post


Link to post
Share on other sites
I have recently done something like this, our CS project at school was a database app for a real company.

I used Visual Basic with MySQL as it was the easiest way to do it. You can use MySQL with C++ tho i never looked at it myself.

Visual Basic is pretty much one of THE languages for databases (modern language that is).

Share this post


Link to post
Share on other sites
name of the book is Ivor Horton''s (sorry not Norton''s) Beginning C++ (The Complete Language)

The only thing I can find that seems to be somewhat valid is this:

Chapter 19: Input and Output Operations

(there is some above then - )

Files Streams
- Writing to a File
- Reading from a File
- Setting the File Open Mode
Managing the Current Stream Posistion

http://www.amazon.com/gp/reader/186100012X/ref=sib_dp_pt/103-9536725-5190207#reader-page

there you can view the first few pages, as you can see I posted the above from Chapter 19.

Kind regards,
Yip

Share this post


Link to post
Share on other sites
I am not sure on this,but you maybe want to have a look:

If you are using MS Visual C++, you should look for CDatabase and DAO-objects to programm your database or have access to ODBC-databases.




The Wild Wild West - Desperado!

[edited by - Wildwest on November 6, 2003 3:00:30 PM]

Share this post


Link to post
Share on other sites
Is it REALLY that hard to make your own database format (I''m assuming that statement in quotes in the instructor''s) It doesn''t seem hard to me to create a basic database structure, and then be able to add and remove records. Maybe I''m missing something

Seems like a good application for templated classes, though.

-=Peon=- : A Poorly Implement Forum Bot
© Kordova, 2003

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Y''know guys, a ''Database'' of student records (really a plain text file) is a really common assignment in intro C++ courses.

You might all be overcomplicating the assignment.

YipMan, you might want to post the assignment''s requirements in more detail. You may have inadvertendly asked for something a lot more complicated than you meant to.

Share this post


Link to post
Share on other sites
For one lab in my C++ class lat quarter, I had to create a music database. The data was from a plain text file, and was read in by the program and placed in memory, almost like records (database records, that is). You didn''t ahve to actually have the music files, but that was the premise for the lab - keeping track of music files. It was an interesting assignemnt, and took a fair bit of work to finish. Although I had about a month to do it.

Grant Palin

Share this post


Link to post
Share on other sites
Hmmm does your course happen to be 122? Taught by a grad student because if so than you and I are in the same boat , I''m having trouble reading the string in and then converting it into integers so my program can handle said integers, I''m trying to use System::IO::StreamReader, and handing that down to a System::String called RawData then I have to convert RawData to an int using RawData->ToInt32 but I need something called a IFormatProvider. Did that make any sense whatsoever if so any help converting a System::String to an int?

Share this post


Link to post
Share on other sites
Int32.Parse(myString) sounds like something you could use. Although String should implement the IConvertible interface, meaning ToInt32 should be defined.

EDIT: Apparently MSDN says not to use the explicit implementation of ToInt32 and to use the Convert class instead. So System.Convert.ToInt32(myString). I'm using C# syntax BTW.

[edited by - Zipster on May 2, 2004 1:42:40 AM]

Share this post


Link to post
Share on other sites