Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help! How to create a database dynamically??

Posted on 2000-02-25
17
Medium Priority
?
209 Views
Last Modified: 2013-11-20
Hi,

There is a listbox in a dialog, which contains the names of some attributes.

after the user chooses some attributes, i want to create a new databse with these names (the values can be obtained from the old database). Anyone knows how to do that? samples are welcomed!

 Pls Help! I need to solve it urgently!
 Thanks a lot!

0
Comment
Question by:greenbird
[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
  • 6
  • 4
  • 3
  • +3
17 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 2557650
just listening ...
0
 

Author Comment

by:greenbird
ID: 2557722
Hi, zoppo,

???? what do u mean huh? can not get it leh...

pls help me!
thanks a lot!
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2557735
sorry, but I can't help you ...

I just added this comment to be notified when comments/answers are posted, because I'm interested too ... it's usual in EE to do this if one does not have to say anything to a question but wants to know what's going on...

ZOPPO
0
Technology Partners: 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!

 
LVL 4

Expert Comment

by:pagladasu
ID: 2557783
What will you be using? DAO or ODBC
0
 
LVL 4

Expert Comment

by:inpras
ID: 2557795
What database?
MS Access, Oracle.....?????
0
 

Author Comment

by:greenbird
ID: 2557820
Hi,

It is Ms Access. i prefer not to use ODBC. that is i want to create a .mdb database at runtime.

thanks a lot!
0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2557822
I am not quite clear what you want.

1. Database can be created dynamically but what kind of database you want to create? Access, ORACLE, Sybase etc.
2. Do you want to use DAO or ODBC? If you have Access, it is preferable to use MFC DAO classes. ODBC otherwise.

Could you describe in detail? This will help us to answer you correctly and fast.

All the best.

Vicky
0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2557861
Sorry. I did not refresh before posting comment.
0
 
LVL 4

Accepted Solution

by:
inpras earned 40 total points
ID: 2557869
Have a tamplate of MS Acces database with no tables in it
When User chooses to create a database copy the template to the user desired name then open it using either ODBC or DAO

then use
CDatabase database;
database.Open(...);

database.ExecuteSQL("CREATE TABLE tablename Col1 Prop1, Col2 Prop2");
in case U use CDatabase

or if U use CDaoDatabase then
CDatabase database;
database.Open(...);

database.ExecuteSQL("CREATE TABLE tablename Col1 Prop1, Col2 Prop2");

These Prop1, Prop2 etc depend on what UR user has selected in ListBox

Hope this helps
inpras
0
 
LVL 4

Expert Comment

by:inpras
ID: 2557873
to copy tamplate U can use CopyFile(.....);
0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2557897
What you want is already there in MSDN sample DaoTable. You can use most of that for your app. Don't waste you time redoing that.
0
 

Author Comment

by:greenbird
ID: 2557909
Hi, all,

thanks so much for ur kind help!

i will try it out as inpras said. if got any problem, i will come back here again :)

Thanks a million for all the help!
0
 

Author Comment

by:greenbird
ID: 2557934
Hi,

i did not refresh when i post the comment :)

Bapat, is it? i will check DaoTable soon, see whether they are what i want. thanks a lot!
0
 

Author Comment

by:greenbird
ID: 2558034
Hi, all,

does anyone know how to get the name from the edit box? that is, i ask the user to enter a name in an edit box, then how do i get the name?

Thanks a lot!
0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2558065
CString strName;
m_edit.GetWindowText(strName);
0
 

Author Comment

by:greenbird
ID: 2560632
Hi,

is
database.ExecuteSQL("CREATE TABLE tablename Col1 Prop1, Col2 Prop2");

the syntex correct? it always gives me an error message.

i find in web the SQL command is :

create table table_name (field_type field_name...)
but it also not correct one...

any one know the correct syntex ? or where to look it up in the web?

thanks a  lot!
0
 
LVL 3

Expert Comment

by:ghimireniraj
ID: 2563405
create table table_name(a varchar2,
b date,c int,
d date)


but watch out
the data types may be diff with diff
databases

you can't use varchar2 in SQl SERVER
or number

you can't use numeric in oracle


hope this helps


niraj
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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

671 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