I have textBoxes in my application. The data entered in those textBoxes are to be inserted in the database. The commandString accepts string type only. So, how can I implement the insert statement?
string cmdString="INSERT INTO books (name,author,price) VALUES (//what to put in here?)"
Do I need to join the cmdString with textBox.Text for each value or is there a better alternative available?
use
Command
andParameter
to prevent fromSQL Injection
full code:
You want to protect yourself from SQL Injection. Building up sql from strings is if not bad practice, at least very scary.
How To: Protect From SQL Injection in ASP.NET http://msdn.microsoft.com/en-us/library/ff648339.aspx
50 ways to inject your sql http://www.youtube.com/watch?v=5pSsLnNJIa4
Entity Framework http://msdn.microsoft.com/en-us/data/ef.aspx