Strange error message

G

Guest

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

Guest

cashdeskmac,

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

Kerry Moorman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top