Home All Groups Group Topic Archive Search About
Author
20 Aug 2006 1:24 PM
cashdeskmac
I am inserting a new record into a table which has 4 columns, the first being
an identity column.  I am adding three strings to the other 3 columns using
an ExecuteNonQuery.  I have set the values of the parameters for the
InsertCommand.

The error I am getting is that the Input is not in the correct format for
SqlCommand.ExecuteReader(CommandBehaviour cmdBehaviour, RunBehaviour
runBehavious, Boolean returnStream)

My SelectCommand insert the three values and returns all 4, including the
Identity column.  My command is:

this.sqlInsertCommand1.CommandText = "INSERT INTO Customers(CustName,
CustAddress, CustPhone) VALUES (@CustName, @CustAddress, @CustPhone); SELECT
CustID, CustName, CustAddress, CustPhone FROM Customers WHERE (CustID =
@@IDENTITY)";

The only parameter I had to create was the @CustID parameter and it is the
same type and size as the CustID column in the table I created.

Can anyone suggest why I am getting this error?

Author
20 Aug 2006 6:11 PM
Kerry Moorman
cashdeskmac,

What happens if you do the insert using ExecuteNonQuery and THEN do the
Select using ExecuteReader?

Kerry Moorman

Show quote
"cashdeskmac" wrote:

> I am inserting a new record into a table which has 4 columns, the first being
> an identity column.  I am adding three strings to the other 3 columns using
> an ExecuteNonQuery.  I have set the values of the parameters for the
> InsertCommand.
>
> The error I am getting is that the Input is not in the correct format for
> SqlCommand.ExecuteReader(CommandBehaviour cmdBehaviour, RunBehaviour
> runBehavious, Boolean returnStream)
>
> My SelectCommand insert the three values and returns all 4, including the
> Identity column.  My command is:
>
> this.sqlInsertCommand1.CommandText = "INSERT INTO Customers(CustName,
> CustAddress, CustPhone) VALUES (@CustName, @CustAddress, @CustPhone); SELECT
> CustID, CustName, CustAddress, CustPhone FROM Customers WHERE (CustID =
> @@IDENTITY)";
>
> The only parameter I had to create was the @CustID parameter and it is the
> same type and size as the CustID column in the table I created.
>
> Can anyone suggest why I am getting this error?
>
>

AddThis Social Bookmark Button