?
Solved

c++ MYsql creating databases

Posted on 2003-02-25
3
Medium Priority
?
181 Views
Last Modified: 2010-04-01
can i create a Mysql database in C++
and also add tables:>?????
0
Comment
Question by:purnendughosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 60 total points
ID: 8016742
Sure you can.  You can use SQL to create the tables.  If you're using the mysql client, that might be something like:
MYSQL *db_mysql = mysql_init(NULL);
if(mysql_real_connect(db_mysql, host, user, password, db_name, 0, NULL, 0) == NULL)
{
 // Error
}

if(mysql_query(db_mysql, "CREATE TABLE bob ( col1 varchar(50) )") != 0)
{
  // Error
}
mysql_close(db_mysql);

MySQL++ makes this a little easier, but I've had problems installing it on some systems.
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 8016752
Also, there's a create_db function to create a database.  Or you could just use the "CREATE DATABASE db_name" sql statement like above.  Good luck.
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9845964
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to mnashadka: Grade B

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question