[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Having problems deleting records via the ExecuteNonQuery() command

Thomas Fujita

11/5/2002 11:03:00 PM

Hi,



I have this small application with a DataGrid that lists items from a Sybase
(SQL Anywhere) database.

I'm using the ODBC adapters (ODBCAdapter, Connection and Command) to
manipulate the database.

My problem exists with the delete object.

The delete sql command is straight forward ( delete from table where
table.id = ? ).

Using the ODBCCommand object, I then setup up a Parameters collection for
the '?' via the Properties window.



When I run the application, the first delete I execute occurs fine ( the
record is deleted ). When I try to delete another record, I get an exception
error -



'ERROR [07002][Sybase][ODBC Driver]Count field incorrect'



After a bit of searching, I've learned that this error probably means this:

_______________________

The number of parameters specified in SQLBindParameter was less than the
number of parameters in the SQL statement contained in *StatementText.

SQLBindParameter was called with ParameterValuePtr set to a null pointer,
StrLen_or_IndPtr not set to SQL_NULL_DATA or SQL_DATA_AT_EXEC, and
InputOutputType not set to SQL_PARAM_OUTPUT, so that the number of
parameters specified in SQLBindParameter was greater than the number of
parameters in the SQL statement contained in *StatementText.

__________________________

This definition courtesy of MSDN. The only thing is, how do I fix this?
Here's the code that actually executes the delete command:

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

Try

Dim nResult As Integer

AdptUserMan.DeleteCommand.Parameters("UserID").Value =
UserGrid(UserGrid.CurrentRowIndex, 0).ToString()

ConnUserMan.Open()

nResult = CmdDELUser.ExecuteNonQuery() <- this is where the exception is
thrown

ConnUserMan.Close()

DataFillInit()

Catch ex As Exception

MsgBox(ex.ToString)

Finally

End Try

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

I don't really understand how there might be less or more than 1 parameter
as I've specified. It's as if the somewhere it just appends the
Parameters.Value setting as opposed to replacing the value.

Any help would be appreciated.

Thanks.