PDA

View Full Version : سوال: کمک در ایجاد جدول



na30oom
چهارشنبه 14 خرداد 1393, 15:39 عصر
سلام من میخوام کد بهینه سازی cross joinرا بنویسم
اگر بخوام جدول را از کاربر بگیرم (اسمش ، تعداد سطرها، تعداد ستون هاو نام ستون ها) چه جوری باید اینکارو انجام بدم تو C# و چه جوری باید به پایگاه داده اضافش کنم؟

kavayo
چهارشنبه 14 خرداد 1393, 19:26 عصر
string queryString =
@"
CREATE TABLE MyTable
(
Id int IDENTITY(1,1) PRIMARY KEY CLUSTERED,
Name varchar(50)
)";


using (SqlConnection connection = new SqlConnection(
myConnectionString ))
{
SqlCommand command = new SqlCommand(
queryString, connection);
connection.Open();
command.ExecuteNonReader();
cmd.CommandText = "Insert into info (Id, Name) Values('"+txtId.Text+"' , '"+txtName.Text+"')";
// command.CommandText = @"Insert INTO MyTable Values ('Abe')";
command.ExecuteNonReader();
}