Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

c++ MYsql creating databases

Posted on 2003-02-25
3
Medium Priority
?
182 Views
Last Modified: 2010-04-01
can i create a Mysql database in C++
and also add tables:>?????
0
Comment
Question by:purnendughosh
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

577 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