-1

when i try this code

 public void ExcuteCommand(string stored_procedure, SqlParameter[] param)
    {
        SqlCommand sqlcmd = new SqlCommand();
        sqlcmd.CommandType = CommandType.StoredProcedure;
        sqlcmd.CommandText = stored_procedure;
        sqlcmd.Connection = sqlconnection;

        if (param != null)
        {
            sqlcmd.Parameters.AddRange(param);
        }
        sqlcmd.ExecuteNonQuery();

to execute it , it give me something went wrong like in this pic i use for this Datatables and parameters and stored procedure this is what show when i try to run the code

2 Answers2

1

In your SP you are trying to insert in table ID which has Identity Specification (Autoincrement) property. Remove ID from insert statement and it should work.

Vasyl Zv
  • 3,529
  • 18
  • 34
1

You are trying to insert the value of identity column(ID).

you can turn off this by appending this to your query statement.

SET IDENTITY_INSERT Table_Name OFF 
Mahesh Gareja
  • 1,177
  • 2
  • 10
  • 22