Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I am beginner to .net Development,Please Help

I am developing windows form application by using c# and Vb.Net,visual studio 2010 and .net framework 4.0.
I am using Microsoft SQL Server 2008 as my database.

though,I am new to C# programming , I've created three layer (APP,BLL,DAL).

Now,
my project is growing and regularly I am creating tables and fields. currently I am doing in SQL(by using create table). but , I feel this is not right way to do.

So,
Can anyone please educate me about following

1) How to create Database,Tables and Fields through Code (sample code would be helpful)
2) is it possible to create relational tables ? . Means OITM and ITM1 are Header and Child table where DocEntry is Primary key ?
3) What are the Best practice to maintain data structure, while developing the project?

Thanks and Regards
M G
Posted

1 solution

There is nothing wrong in creating tables and fields directly in the database.
Creating new tables or fields via code is harder to maintain as you have to compile code everytime a new column is added.

However, if you do want to create tables through code, try Creating, Altering, and Removing Foreign Keys[^].
 
Share this answer
 
Comments
mg7 13-Nov-15 2:30am    
Thank you for quick response,

I'will try to create it from code, because I want learn.

can you please tel me how to maintain standard script to maintain creating tables,colums in SQL? because I am creating Tables again and again.

I want to do it in good code practice.

Thanks

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