i am making windows application using c#.i have to develop application that will store student information, etc
and i want a feature through which a user can create empty databse with exisitng design..i mean every year, end-user will create a new database but the design of tables and relations etc will be the same but no data in it..
pls guys is there any method or classes i can use to create database programmaticaly..such as using existing database schema, database template or any other option available
i am using sql server compact, sql server epxress
i am still evaluating both and choose one which fit my reuirment
and if there is any other option available apart from these..pls suggest me
waiting for ur repsonse..
Loading
Kirtan PatelPosted Nov 2, 2009, 7:59 AM
send me your database mdf File in Mail.
[email protected] i will tell you how you have to follow step by step :)
thank you :)
kassimPosted Nov 4, 2009, 1:53 PM
and in case of backup the mdf will be copied to some other location..
ohh gr8 even dat cud be a better option if i backup data without creating new database.
i just need to copy mdf files to other location
and then just truncate tables in an existing root database
do u mean this only or sumthing else
dude..help me out
and thankx for your suggestion
kassimPosted Nov 4, 2009, 1:46 PM
so i dont have .mdf file on hand ready
creating database with schema or suggest me any other option
okay if possible can u just give me breif idea to peform all dis methods
Mahesh ChandPosted Nov 2, 2009, 10:12 AM
What are you going to do with the old database? Why don't you just take a Backup of old database and delete all data from current database? In that case, you don't have to create same database every year.
If you MUST create a new database every year, I suggest you write SQL Queries for your database schema (CRATE TABLE etc) and save them as a SQL Script. Everytime you need to create a new database, just run these scrupts. If you plan to use SQL Server and do not know how to generate SQL scripts, you can first design your database using SQL Server Management Studio and then Export your database schema to a SQL Script by using Export option on the database.
Hope it helps.
kassimPosted Nov 1, 2009, 8:45 AM
how can i execute dat sql file so dat the final output will be a .mdf file
thanks in advance
kassimPosted Nov 1, 2009, 8:32 AM
Kirtan PatelPosted Nov 1, 2009, 6:32 AM
you can create Stored Procedure.. when it execute new Database Schema is Generated
here is Article how you can create automated Table Creation Script
http://blog.sqlauthority.com/2007/08/21/sql-server-2005-create-script-to-copy-database-schema-and-all-the-objects-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/
if my answer helps you please check "Do you like this answer" :)
Mahmoud AlamPosted Nov 1, 2009, 6:05 AM
when user click generate db - you use TSQL to create db on sql express (command will be executed on master db) with generated name
after that you will execute generated script on the new db