Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
cmd.CommandText = "insert into " + table + "values ('" + textBox1.Text + "', '" + textBox2.Text + "');";

i know this is a sipmle query, bt still i dont know why it is showing error...
Posted
Updated 2-Jun-14 20:20pm
v2
Comments
ArunRajendra 3-Jun-14 1:44am    
What's the error?

You have not defined the column names.
cmd.CommandText = "insert into " + table (colA, colB) + "values ('" + textBox1.Text + "', '" + textBox2.Text + "');";


As an aside, you should look at command parameters[^].
Queries like this are dangerous - SQL Injection[^].
 
Share this answer
 
Comments
Maciej Los 3-Jun-14 1:50am    
+5
Abhinav S 3-Jun-14 4:03am    
Thank you.
I guess the problem is there is no space between table and values. Give a space before values.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900