Header Ads

Dynamically created database and table in asp.net and c#

i have created database and table dynamically using asp.net,c# and sqlsample code here............


Con.Open();
string str = "CREATE DATABASE " + Txtdbname.Text;
Cmd = new SqlCommand(str, Con);
Cmd.ExecuteNonQuery();
string str1 = " USE " + Txtdbname.Text;
Cmd1 = new SqlCommand(str1, Con);
Cmd1.ExecuteNonQuery();
string str2 = "CREATE TABLE  product_manager (id INT IDENTITY(1,1) NOT NULL
PRIMARY KEY,"
+"userid varchar(50) NOT NULL,"
+"product_id varchar(50) NOT NULL,"
+"product_name varchar(50) NOT NULL,"
+"product_price varchar(50) NOT NULL,"
+"product_created_date varchar(50) NOT NULL,"
+"product_qty varchar(50) NOT NULL,"
+" product_image varchar(50) NOT NULL,"
+"product_description text,"
+"product_abstract varchar(50) NOT NULL,"
+"product_location varchar(50) default NULL,"
+"category_id varchar(50) NOT NULL,"
+"selling_type varchar(50) NOT NULL,"
+"bidding_start varchar(50) NOT NULL,"
+"bidding_end varchar(50) NOT NULL,"
+" created_date varchar(50) NOT NULL,"
+"shipping_amount varchar(50) NOT NULL,"
+"withindelevery varchar(50) NOT NULL,"
+"  is_active int NOT NULL)";
Cmd2 = new SqlCommand(str2, Con);
Cmd2.ExecuteNonQuery();
Con.Close();

No comments:


Powered by Blogger.