Create a table dynamically in sql from values in textboxes in webform?
-
hey guys, i m trying to create a table dynamically in sql from the values entered by user in two textboxes in asp.net using c#, i have tried with the below snippet of code but its giving error, Please help friends asap, waiting for reply protected void Button1_Click(object sender, EventArgs e) { conn.Open(); cmd = new SqlCommand("Insert into standard VALUES(@st,@di)", conn); cmd.Parameters.AddWithValue("@st", std.Text); cmd.Parameters.AddWithValue("@di", div.Text); cmd.ExecuteNonQuery(); cmd = new SqlCommand("Create table class'" + std.Text + div.Text + "'(rollno int primary key, std nchar(10), div nchar(10),name text,pwd text)'", conn); //cmd = new SqlCommand("Create table std'" +@st+"'div'"+@di+ "'(rollno int primary key,std nchar(10), div nchar(10),name text,pwd text)'", conn); cmd.ExecuteNonQuery(); }
-
Answer:
Risky..very risky. You're just asking for an sql injection attack...
neelam at Yahoo! Answers Visit the source
Related Q & A:
- How to dynamically create a PHP class name on the fly?Best solution by stackoverflow.com
- How to add primary key from multiple table as a foreign key in a table in sql server 2008?Best solution by stackoverflow.com
- What is Hash Table, how to create a hash table?Best solution by Stack Overflow
- How to create a table in PHP with MySQL?Best solution by Stack Overflow
- How to create a table in gmail?Best solution by Web Applications
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.