Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am new to C# pretty new to c# and I have to create an aplication which creates a database dynamicly (or at least tables in a database). Is there any wat to do that?

thanks and please excuse my english
Posted

You should investigate the SQL Server Management Objects (SMO)
as one route to achieve your goal.

Other than that Google/Bing/Yahoo should be your constant companion. You will get far more help from there than you are likely to get here.
 
Share this answer
 
Try this library (but it supposes you have a database already created).

DBKeeperNet - Keeps Your DB Schema Up-to-date[^]

You can also use ADO.NET DbCommand and run SQL commands directly.
 
Share this answer
 
v2
If you are just looking for code to create a database - see Create a SQL Server Database Using C#
 
Share this answer
 
Assuming you are using SQL Server, you can do this using SQL Management Objects. If you google for SMO C#, you should get plenty of hits detailing how to use this.
 
Share this answer
 
If your going to do it right! and you can use VS2010.

I would suggest using Entity Framework 4.3, it fully supports now database migration scripting too. So - when you change the definition of your class, it generates the DB Schema update - and therefore generates script, and even executes it on your DB. supports SQL Server, Express and even SQL Compact.

SMO is another good option.

Look in google on "Nerd Dinner MVC app" - its really good example of how EntityFramework works with MVC.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900