inserting a row into table from the form data
-
Hi Friend'z... I want to enter a row data to the sql server table, from the data entered by the user in the windows form. I hav a query string str="insert into books values ("+'@textBox1.Text'+","+'@textBox2.Text'+")"; what is wrong in this? pl help me in doing.... thanks in advance :):confused:
-
Hi Friend'z... I want to enter a row data to the sql server table, from the data entered by the user in the windows form. I hav a query string str="insert into books values ("+'@textBox1.Text'+","+'@textBox2.Text'+")"; what is wrong in this? pl help me in doing.... thanks in advance :):confused:
-
Hi Friend'z... I want to enter a row data to the sql server table, from the data entered by the user in the windows form. I hav a query string str="insert into books values ("+'@textBox1.Text'+","+'@textBox2.Text'+")"; what is wrong in this? pl help me in doing.... thanks in advance :):confused:
-
Hi Friend'z... I want to enter a row data to the sql server table, from the data entered by the user in the windows form. I hav a query string str="insert into books values ("+'@textBox1.Text'+","+'@textBox2.Text'+")"; what is wrong in this? pl help me in doing.... thanks in advance :):confused:
Try
SQLstr="insert into books ({col1}, {col2}) values ('" & textBox1.Text & "', '" & textBox2.Text & "')";
(This is VB ... I'm not sure what language you're using ... the important thing is the {col1} and {col2} which are the names of the table colums that @textBox1 and @textBox2 are going to be inserted into) I find that a good debug tip is to use Query Analyser to test the structure of my SQL statement before I insert it into code. So I would try something likeINSERT INTO books VALUES ('SQL Programming', 'Robert Vieira')
and when that didn't work I'd tryINSERT INTO books (title, author) VALUES ('SQL Programming', 'Robert Vieira')