Solved

Help! How to create a database dynamically??

Posted on 2000-02-25
17
199 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
  • 6
  • 4
  • 3
  • +3
17 Comments
 
LVL 30

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 30

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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 4

Accepted Solution

by:
inpras earned 10 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
function returning CString in a regular win32 DLL 8 150
Sed question 2 49
Making an alias 7 54
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now