By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,452 Members | 1,571 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,452 IT Pros & Developers. It's quick & easy.

Insert in OleDb does not work

P: n/a
mp
I have example like follows:

OleDbCommand InsertCommand =
new OleDbCommand("INSERT INTO RecnikTable VALUES (@ENGLESKI, @SRPSKI)",
thisConnection);
InsertCommand.Parameters.Add("@ENGLESKI", OleDbType.VarChar);
InsertCommand.Parameters.Add("@SRPSKI", OleDbType.VarChar);

string[] reci = {textBox2.Text, textBox2.Text};
InsertCommand.Parameters["@ENGLESKI"].Value=reci[0];
InsertCommand.Parameters["@SRPSKI"].Value=reci[1];

This does not work.

If I use hard coded values instead reci[0] it does not work too. Interesting
is, if I use this example like command line project everything works
perfectly.

Does somebody know what is wrong?

Thanks

Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
mp,
You forgot your fields in the INSERT command. Try
INSERT INTO RecnikTable field1, field2 VALUES
using, of course your own field names.

Ron Allen
"mp" <pl****@volja.net> wrote in message
news:uP**************@tk2msftngp13.phx.gbl...
I have example like follows:

OleDbCommand InsertCommand =
new OleDbCommand("INSERT INTO RecnikTable VALUES (@ENGLESKI, @SRPSKI)",
thisConnection);
InsertCommand.Parameters.Add("@ENGLESKI", OleDbType.VarChar);
InsertCommand.Parameters.Add("@SRPSKI", OleDbType.VarChar);

string[] reci = {textBox2.Text, textBox2.Text};
InsertCommand.Parameters["@ENGLESKI"].Value=reci[0];
InsertCommand.Parameters["@SRPSKI"].Value=reci[1];

This does not work.

If I use hard coded values instead reci[0] it does not work too. Interesting is, if I use this example like command line project everything works
perfectly.

Does somebody know what is wrong?

Thanks

Nov 15 '05 #2

P: n/a
"Tu-Thach" <tu*****@antispam.ongtech.com> wrote in message news:<A0**********************************@microso ft.com>...
OleDb uses ? for parameters instead of @ENGLSKI, @SRPSKI.

Tu-Thach

----- mp wrote: -----

I have example like follows:

OleDbCommand InsertCommand =
new OleDbCommand("INSERT INTO RecnikTable VALUES (@ENGLESKI, @SRPSKI)",
thisConnection);
InsertCommand.Parameters.Add("@ENGLESKI", OleDbType.VarChar);
InsertCommand.Parameters.Add("@SRPSKI", OleDbType.VarChar);

string[] reci = {textBox2.Text, textBox2.Text};
InsertCommand.Parameters["@ENGLESKI"].Value=reci[0];
InsertCommand.Parameters["@SRPSKI"].Value=reci[1];

This does not work.

If I use hard coded values instead reci[0] it does not work too. Interesting
is, if I use this example like command line project everything works
perfectly.

Does somebody know what is wrong?

Thanks

Maybe you forgot to do an InsertCommand.ExecuteNonQuery at the end of your code???

Michel
Nov 15 '05 #3

P: n/a
mp
I am sorry. Here is not solution.
I am confused because averything works with command line project but not
with win app.

Thanks

"Michel R." <mi*********@videotron.ca> wrote in message
news:8f**************************@posting.google.c om...
"Tu-Thach" <tu*****@antispam.ongtech.com> wrote in message news:<A0**********************************@microso ft.com>...
OleDb uses ? for parameters instead of @ENGLSKI, @SRPSKI.

Tu-Thach

----- mp wrote: -----

I have example like follows:

OleDbCommand InsertCommand =
new OleDbCommand("INSERT INTO RecnikTable VALUES (@ENGLESKI, @SRPSKI)", thisConnection);
InsertCommand.Parameters.Add("@ENGLESKI", OleDbType.VarChar);
InsertCommand.Parameters.Add("@SRPSKI", OleDbType.VarChar);

string[] reci = {textBox2.Text, textBox2.Text};
InsertCommand.Parameters["@ENGLESKI"].Value=reci[0];
InsertCommand.Parameters["@SRPSKI"].Value=reci[1];

This does not work.

If I use hard coded values instead reci[0] it does not work too. Interesting is, if I use this example like command line project everything works perfectly.

Does somebody know what is wrong?

Thanks

Maybe you forgot to do an InsertCommand.ExecuteNonQuery at the end of your

code???
Michel

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.