Basic c++ and database interaction questions

J

Jasper

I have a noob problem that is fairly expansive. Let me preface it by
saying that I'm a beginning programmer and am using the game I'm
writing as a learn-as-I-go tool. I'm trying to make a
sports-management game that pulls extensive team and player data from
a database to simulate matches and such. I'm not really clear on what
would be a good database to use and the process of accessing it. My
criteria is the following -
1 - The user shouldn't have to install any services outside of the
setup package - basically my parents should be be able to install and
run it
2 - I would like it to be OS (Linux, Windows) independent, though I
think that's probably wishful thinking

I currently have MS-SQL server setup and am using MS-VC++ 6 (the
application is a console app however), but I'm not really clear how to
go about connecting to it. I was looking at using ADO but that sounds
like it's a Microsoft specific way of doing it.
On top of that problem, I really have no idea what I'm doing as far as
what libraries I should include and the function calls to make. I've
googled for the last couple of days looking for a tutorial or anything
that could guide me through it and even went to the local techie book
store without any luck. If anyone can point me towards a walkthrough
or provide insight I would really appreciate it, even if it's to go
RTFM - just tell me where the FM is. =)
 
V

Victor Bazarov

Jasper said:
I have a noob problem that is fairly expansive. [...]
I currently have MS-SQL server setup and am using MS-VC++ 6 (the
application is a console app however), but I'm not really clear how to
go about connecting to it.

This is not a C++ language issue. Try asking in a VC++ newsgroup
or in a MS SQL server newsgroup.
I was looking at using ADO but that sounds
like it's a Microsoft specific way of doing it.

It probably is, so? You need to connect two Microsoft products.
Why not use a Microsoft way of doing it?
On top of that problem, I really have no idea what I'm doing as far as
what libraries I should include and the function calls to make.

And on top of that, you have no idea where to post your questions
either. Start by reading the Welcome message posted here weekly
and the FAQ.
I've
googled for the last couple of days looking for a tutorial or anything
that could guide me through it and even went to the local techie book
store without any luck. If anyone can point me towards a walkthrough
or provide insight I would really appreciate it, even if it's to go
RTFM - just tell me where the FM is. =)

Visit www.amazon.com and look for Microsoft SQL server programming.
For starters, I mean. Before you even ask anything in a Microsoft
newsgroup, that is.

Here it's all off-topic.

Victor
 
J

Jasper

Actually it is C++, not VC++ since it's a console app. If it makes
you feel better I can say that I'm writing it with Bloodshed Dev-C++
which is what I started it on. Second, I didn't say I was set on
MS-SQL server, on the contrary I don't think it's what I need. I've
been pointed towards mySQL by people who read (and understood) my post
before responding. So where is the relevance of this being posted in
an MS specific newsgroup, especially when I clearly stated I was
looking for a solution that was OS independent?
And thanks for the amazon link, I guess I forgot to mention that I
already browsed through Powell's Tech for an hour or so and didn't see
any books that were specifically targetted at C++ and SQL interaction.
All the SQL books I found were specifically aimed at setting up and
querying the database, which I already own books for. Oh wait, I did
mention it.
If it's a failure on my part to communicate what I was asking for
correctly, I apologize, though I would have preferred you not to
answer if you didn't understand. Thanks!


Jasper said:
I have a noob problem that is fairly expansive. [...]
I currently have MS-SQL server setup and am using MS-VC++ 6 (the
application is a console app however), but I'm not really clear how to
go about connecting to it.

This is not a C++ language issue. Try asking in a VC++ newsgroup
or in a MS SQL server newsgroup.
I was looking at using ADO but that sounds
like it's a Microsoft specific way of doing it.

It probably is, so? You need to connect two Microsoft products.
Why not use a Microsoft way of doing it?
On top of that problem, I really have no idea what I'm doing as far as
what libraries I should include and the function calls to make.

And on top of that, you have no idea where to post your questions
either. Start by reading the Welcome message posted here weekly
and the FAQ.
I've
googled for the last couple of days looking for a tutorial or anything
that could guide me through it and even went to the local techie book
store without any luck. If anyone can point me towards a walkthrough
or provide insight I would really appreciate it, even if it's to go
RTFM - just tell me where the FM is. =)

Visit www.amazon.com and look for Microsoft SQL server programming.
For starters, I mean. Before you even ask anything in a Microsoft
newsgroup, that is.

Here it's all off-topic.

Victor
 
D

Default User

Jasper said:
I have a noob problem that is fairly expansive. Let me preface it by
saying that I'm a beginning programmer and am using the game I'm
writing as a learn-as-I-go tool.

Games are excellent learning tools.
I'm trying to make a
sports-management game that pulls extensive team and player data from
a database to simulate matches and such. I'm not really clear on what
would be a good database to use and the process of accessing it. My
criteria is the following -
1 - The user shouldn't have to install any services outside of the
setup package - basically my parents should be be able to install and
run it
2 - I would like it to be OS (Linux, Windows) independent, though I
think that's probably wishful thinking

I'd say a text-based flat-file system would fit the needs here. How much
information are we talking about? You'd be surprised (pleasantly) at how
quickly a C++ app can chug through a data file with current hardware. If
there isn't too much, you can probably load all the data records into
memory. I'd look at something like line-separated records with
tab-separated data fields.

A relational database like you mention in stuff I am going to snip is
another way to go, IF your goal is to learn SQL or some other query
language. If not, and you want to learn C++, then don't get wrapped up
with the other thing.

I'd write it as a straight 100% ISO standard C++ program at the
beginning. That gives you maximum portability. Later you can look at
enhancements that may be platform specific (which would be off-topic
here).

I hope this helps. You'd need to define your class hierarchy for the
game elements and decide on your data record structure. That's not
really topical here either, perhaps comp.programming, but once you get
that we can certainly help with implementation.



Brian Rodenborn
 
V

Victor Bazarov

Jasper said:
[...]
If it's a failure on my part to communicate what I was asking for
correctly, I apologize, though I would have preferred you not to
answer if you didn't understand. Thanks!

C++ _language_ has no means to communicate with any databases.
It's all done through libraries supplied by database vendors or
by third parties. Discussing programming issues with those
libraries is beyond the scope of this newsgroup.

If I didn't make myself clear in my first reply, I apologize,
though I would have preferred you not to post off-topic crap here
in the first place, but you probably already knew that. Thanks!
 
J

Jasper

Thanks a ton to both Daniel and DU. You gave me a lot to think about
and gave me an FM to read. =) I appreciate it.
 
S

Shailesh Humbad

Jasper said:
I have a noob problem that is fairly expansive. Let me preface it by
saying that I'm a beginning programmer and am using the game I'm
writing as a learn-as-I-go tool. I'm trying to make a
sports-management game that pulls extensive team and player data from
a database to simulate matches and such. I'm not really clear on what
would be a good database to use and the process of accessing it. My
criteria is the following -
1 - The user shouldn't have to install any services outside of the
setup package - basically my parents should be be able to install and
run it
2 - I would like it to be OS (Linux, Windows) independent, though I
think that's probably wishful thinking

I think what would work for you is SQLite:

http://www.sqlite.org/

It is freeware and has a very simple API. It does not run as a
service like MySQL or MS SQL, and the whole database is stored in a
single file. You should be able to find sample code in Google and by
reading the documentation.
 
D

David

I have a noob problem that is fairly expansive. Let me preface it by
saying that I'm a beginning programmer and am using the game I'm
writing as a learn-as-I-go tool. I'm trying to make a
sports-management game that pulls extensive team and player data from
a database to simulate matches and such. I'm not really clear on what
would be a good database to use and the process of accessing it. My
criteria is the following -
1 - The user shouldn't have to install any services outside of the
setup package - basically my parents should be be able to install and
run it
2 - I would like it to be OS (Linux, Windows) independent, though I
think that's probably wishful thinking

I currently have MS-SQL server setup and am using MS-VC++ 6 (the
application is a console app however), but I'm not really clear how to
go about connecting to it. I was looking at using ADO but that sounds
like it's a Microsoft specific way of doing it.
On top of that problem, I really have no idea what I'm doing as far as
what libraries I should include and the function calls to make. I've
googled for the last couple of days looking for a tutorial or anything
that could guide me through it and even went to the local techie book
store without any luck. If anyone can point me towards a walkthrough
or provide insight I would really appreciate it, even if it's to go
RTFM - just tell me where the FM is. =)

Jasper,

I agree with Brian that the best method, especially for a learn as
you go project, might be to code the database portion yourself. It
all depends on what you want and need. Judging from your post, I'd
say you don't know what kind of database is needed and have just
used and mentioned a few that people know about.

Another option for a C based database program is from FairCom and
I think it was called c-tree. The cost a few years ago was about
$300. I was given the DB Admin job for their databases. Anyway
you get the full source code and they support a couple dozen
systems. Beats the price of most other products any day. There
are also some public domain light databases but I don't know any
off the top of my head.

Unless you have an absolutely huge amount of data to play with,
or truely need a relational database, or need to access said
database with outside tools, its not worth it to bother. Writing
it all yourself will keep it portable, fast, and a slightly better
learning experience.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top