Re: SqlException after Adapter.Update: how to determine the source column and parameter involved?

Tech-Archive recommends: Speed Up your PC by fixing your registry





You could try removing all of the fields from the query except one, and see if that works. Then add them back one at a time until you figure out which one it is.

It looks like you are putting the value 'Test' into a column that is an integer in the database, from your error message. So what column are you putting 'Test' into? Maybe your parameters are off.

RobinS.
GoldMail.com


"TR" <__@xxxxxx> wrote in message news:OdxAAwGiIHA.2540@xxxxxxxxxxxxxxxxxxxxxxx
I am at this point (<<<) in my Insert logic against a SQL2000 back-end:

Try

...

MyDataset.Tables(0).DefaultView.RowStateFilter = DataViewRowState.Added

If MyDataset.Tables(0).DefaultView.Count > 0 Then
Adapter.Update(MyDataset.Tables(0))
End If

Catch ex as Exception
RaiseEvent MyErrorEvent(ex) '<<< here
Finally
End Try

The code is raising a SqlClient.SqlException:


{"Syntax error converting the varchar value 'Test' to a column of data type int."}

Since there are multiple integer-type columns in the table, it would be very helpful to know which of them is the one involved in the SqlException. === Is it possible to determine that in the debugger? ===

I think the exception may be spurious, for when I look at things in the Immediate Window, it all looks OK:

?adapter.InsertCommand.Parameters("@addr1").Value
"Test" {String}
String: "Test"


The correct column is being updated with the value 'Test'. I don't see any parameters with incorrect SourceColumn mappings, and "addr1" the source column for parameter("@addr1") is not used more than once in the code where the parameters are instantiated. And in the stored procedure, the insert(column-list) values(param-list) has correct column-parameter match up.

Thanks
TR


.



Relevant Pages

  • Re: SqlException after Adapter.Update: how to determine the source column and parameter involved?
    ... RaiseEvent MyErrorEvent'<<< here ... I think the exception may be spurious, for when I look at things in the Immediate Window, it all looks OK: ... The correct column is being updated with the value 'Test'. ... I don't see any parameters with incorrect SourceColumn mappings, and "addr1" the source column for parameteris not used more than once in the code where the parameters are instantiated. ...
    (microsoft.public.dotnet.framework.adonet)
  • SqlException after Adapter.Update: how to determine the source column and parameter involved?
    ... {"Syntax error converting the varchar value 'Test' to a column of data type int."} ... I think the exception may be spurious, for when I look at things in the Immediate Window, it all looks OK: ... The correct column is being updated with the value 'Test'. ... I don't see any parameters with incorrect SourceColumn mappings, and "addr1" the source column for parameteris not used more than once in the code where the parameters are instantiated. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: HasRows() vs. Read() and ERROR suppression
    ... > record found by executing the commandText. ... >> Syntax error converting datetime from character string. ... >> on the Command object, ... >> MUST call .Readon the SqlDataReader, or you don't get the exception. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Stored Proc using MS Application Blocs
    ... I would like to confirm my understanding of your issue. ... exception it is, so that I can decide where the exception was thrown? ... If this is a SQL server error ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: HasRows() vs. Read() and ERROR suppression
    ... The Read method (when called for the first time) advances you to the first ... > Syntax error converting datetime from character string. ... > on the Command object, ... > MUST call .Readon the SqlDataReader, or you don't get the exception. ...
    (microsoft.public.dotnet.framework.adonet)