更新时间:2023-11-24 21:53:34
试试这个.....
try this.....
SqlCommand com;
string str;
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "ALTER TABLE [dbo].[new] ADD " + TextBox1.Text.ToString() + " Varchar(50) NULL ";
com = new SqlCommand(str,con);
com.ExecuteNonQuery();
con.Close();
如果某些值(例如结束日期)可以从现有参数(例如月份数和开始日期)派生,则没有理由存储它。只需存储月数和开始日期即可。
尝试向关系表添加新列更糟糕。重新查看您的数据库设计。
1. http:/ /www.datanamic.com/support/lt-dez005-introduction-db-modeling.html [ ^ ]
2. http://www.studytonight.com/dbms/database-normalization.php [ ^ ]
If some value such as end date can be derived from existing parameters like number of month and start date, then there is no reason to store it. Just store the number of month and start date will suffice.
It is even worse trying to add new columns to relational table. Re-look your database design.
1. http://www.datanamic.com/support/lt-dez005-introduction-db-modeling.html[^]
2. http://www.studytonight.com/dbms/database-normalization.php[^]