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?

RE: Strange error message by KerryMoorman

KerryMoorman
Sun Aug 20 13:11:02 CDT 2006

cashdeskmac,

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

Kerry Moorman

"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?
>
>