D
DM
Hello.
I have following problem with SqlCeDataAdapter.
Let's take this code as an example:
....
SqlCeAdapter Adapter = new SqlCeAdapter();
SqlCeCommand command = conn.CreateCommand();
command.CommandText =
"INSERT INTO " +
" table " +
" ( " +
" column, " +
" id
" ) " +
"VALUES " +
" ( " +
" REPLACE ( ?, 'a', '' ), " +
" ? " +
" )";
command.Parameters.Add( new SqlCeParameter("@column", DbType.NChar, 20, "column");
command.Parameters.Add( new SqlCeParameter("@id", DBType.Int, 4, "id" );
Adapter.InsertCommand = command;
After adding a row to a DataTable, when I call:
Adapter.Update( table );
There is a SqlCeException excpetion with MissingParameterException error
(it's because of the replace function)
Wheras the following works just fine:
SqlCeCommand command2 = conn.CreateCommand();
command2.CommandText =
"UPDATE " +
" table " +
"SET " +
" column = REPLACE ( ?, 'a', '' )
"WHERE " +
" id = ? "
command2.Parameters.Add( new SqlCeParameter("@column", DbType.NChar, 20, "column");
command2.Parameters.Add( new SqlCeParameter("@id", DBType.Int, 4, "id" );
Adapter.UpdateCommand = command2;
after making changes to a row:
Adapter.Update(table);
works like charm.
I don't know why the update command works while insert fails.
Is there sth wrong with my query or is it a bug?
Thanks for any suggestions.
I have following problem with SqlCeDataAdapter.
Let's take this code as an example:
....
SqlCeAdapter Adapter = new SqlCeAdapter();
SqlCeCommand command = conn.CreateCommand();
command.CommandText =
"INSERT INTO " +
" table " +
" ( " +
" column, " +
" id
" ) " +
"VALUES " +
" ( " +
" REPLACE ( ?, 'a', '' ), " +
" ? " +
" )";
command.Parameters.Add( new SqlCeParameter("@column", DbType.NChar, 20, "column");
command.Parameters.Add( new SqlCeParameter("@id", DBType.Int, 4, "id" );
Adapter.InsertCommand = command;
After adding a row to a DataTable, when I call:
Adapter.Update( table );
There is a SqlCeException excpetion with MissingParameterException error
(it's because of the replace function)
Wheras the following works just fine:
SqlCeCommand command2 = conn.CreateCommand();
command2.CommandText =
"UPDATE " +
" table " +
"SET " +
" column = REPLACE ( ?, 'a', '' )
"WHERE " +
" id = ? "
command2.Parameters.Add( new SqlCeParameter("@column", DbType.NChar, 20, "column");
command2.Parameters.Add( new SqlCeParameter("@id", DBType.Int, 4, "id" );
Adapter.UpdateCommand = command2;
after making changes to a row:
Adapter.Update(table);
works like charm.
I don't know why the update command works while insert fails.
Is there sth wrong with my query or is it a bug?
Thanks for any suggestions.