English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

For eg:
command=new oledbcommand("INSERT INTO table(COL) VALUES(textbox1.text)
I get a error. Actually my program is not able to get the value from textbox1.text

2007-04-01 01:50:39 · 4 answers · asked by crickwiz 2 in Computers & Internet Programming & Design

4 answers

In C#:

string strSQL = "INSERT INTO tablename (columnname) VALUES '" + textbox1.text + "'";
OleDbCommand command = new OleDbCommand(strSQL);

In VB.NET:

Dim strSQL As String = "INSERT INTO tablename (columnname) VALUES '" + textbox1.text + "'"

Dim command As OleDbCommand = New OleDbCommand(strSQL);

2007-04-01 05:45:55 · answer #1 · answered by Anonymous · 0 1

It really depends on what language you are using.

You'll definitely need to quite the text though so it should be

Values('textbox1.text')

You'll also need to substitute in the value of textbox1.text

So you could do:
command = new oledbcommand("INSERT INTO table(COL) VALUES('" & textbox1.text & "')")

(Replace the & with whatever operand for string concatenation is used in your language.

2007-04-01 02:30:42 · answer #2 · answered by Vegan 7 · 0 1

command=new oledbcommand("INSERT INTO table(COL) VALUES('" & textbox1.text & "')

to pass the value from text box, you should concatenate the value with the sql correctly.

2007-04-01 09:31:04 · answer #3 · answered by r_ranjith 4 · 0 1

hi
your problem is syntax related.

you are about to insert int to field that must be var char type.

try this

insert into table(COL) values('textbook1.text')

2007-04-01 03:17:14 · answer #4 · answered by G K 2 · 0 2

fedest.com, questions and answers