Based on your clarification in the comment it is clear that you are trying to INSERT a value into the table's IDENTITY
column.
Most likely it is the StudId
or the BookID
column.
Remove the identity column from your cmd.Parameters.AddWithValue()
statement and your INSERT string and you should be good.
SQL Automatically inserts this value and increments it based on the previous values.
If your IDENTITY column is StudId
then your insert string should look like:
"Insert into Books (BookId,Title,Author,Description,Price,Owner,Phone_no,ImagePath) values (@bid,@t,@a,@d,@p,@o,@n,@i)"
If your IDENTITY column is BookId
then it should look like:
"Insert into Books (StudId,Title,Author,Description,Price,Owner,Phone_no,ImagePath) values (@sid,@t,@a,@d,@p,@o,@n,@i)"
Then just delete the cmd.Parameters.AddWithValue()
line for the related parameter.