PDA

View Full Version : تعریف یک فیلد در زمان اجرا و با کدنویسی؟؟؟؟؟



setareh69
چهارشنبه 18 مرداد 1391, 15:27 عصر
سلام
آیا میشه از طریق کدنویسی و در زمان اجرا یک فیلد از نوع nvarchar(max ایجاد کرد؟؟اگرمیشه کدش چیه؟
ممنون

morika
چهارشنبه 18 مرداد 1391, 15:58 عصر
using (DbConnection connection = new SqlConnection("Your connection string")) {
connection.Open();
using (DbCommand command = new SqlCommand("alter table [Product] add [ProductId] nvarchar(MAX) default 0 NOT NULL")) {
command.Connection = connection;
command.ExecuteNonQuery();
}
}