Read up on MSDN documentation on System.Data.Odbc.OdbcCommand property CommandText

The Odbc provider uses question mark placeholders. It does not support named parameters. You have to use a SQL statement like:

SELECT * FROM SOME_TABLE WHERE SOME_ID = ?

In your parameters, it is positional, not named.

I noticed in your code your are mis-matching. In your SQL statement, you have placeholders, but your creation of the parameters you are using named parameters with an @ symbol. You can not do this.

cStmnt = “UPDATE ComanySTD SET ” +

“ Name1 = ?, ”

“ Name2 = ? ”

“ WHERE PKey = ‘” + cPKey + "‘”


oCommand.Parameters.Add(new OdbcParameter).Value = Textbox_Name1.Text.Trim();

oCommand.Parameters.Add(new OdbcParameter).Value = Textbox_Name2.Text.Trim();

oCommand.ExecuteNonQuery();

If Odbc does not work for you, try Npgsql instead to connect to PostgreSQL.

Jan Waiz wrote:

HI All,

view Days ago i postet Porblems with ODBC and Postgre.

One Answer was testet without solving the Problem so I send it to bugzilla – without any Answer up to know.

Now I am running in Timeproblems for the Project because I can’t finish important Parts of the Application and the Deadline will come! So I am coming in Trouble if I did not found a Solution. Be so kind and let me know:

How did YOU work via ODBC with a SQL-Database – meaning: How did you build Insert- or Updatestatements? And how did you solve the Problem with escaping Signs like <’> or german Signs like “äöü” ? Or did you work with an other SQL-Database in the descriped way without any Problems (*s*) ?

In short I am doing it like this:

cStmnt = “UPDATE ComanySTD SET” +

“Name1 = ?,”

“Name2 = ?”

“WHERE PKey = ‘” + cPKey + ‘”

oCommand.Parameters.Add( [EMAIL PROTECTED], Textbox_Name1.Text.Trim() )

oCommand.Parameters.Add( [EMAIL PROTECTED], Textbox_Name2.Text.Trim() )

oCommand.ExecuteNonQuery()

wich is working fine running under Localhost but makes an Error running under Mono:

System.Data.Odbc.OdbcException: [unixODBC]Unrecognized C_parameter type in 
copy_statement_with_parameters



When changing to:

cStmnt = “UPDATE ComanySTD SET” +

“Name1 = “ + Textbox_Name1.Text.Trim() + ,”

“Name2 = “ + Textbox_Name2.Text.Trim() + ,”

“WHERE PKey = ‘” + cPKey + ‘”

It works. But without excaping! And Signs like “äöü” will shown as Crashed-Signs in a Textbox when showing a Record.

I am playing around with different Ways using Parameter like:

oCommand.Parameters.Add( [EMAIL PROTECTED], OdbcType.varchar, 36 ).Value = Textbox_Name1.Text.Trim()

but everytime the same Runtimeerror.

So – now I am at the end of my Nerves and my Knowledge. Hope, there is anyone outside there, who can tell me, how he is using ODBC-Parameter…

Many Thanks for ANY Help !!!

Jan Waiz

------------------------------------------------------------------------

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to