First off, never do "anonymous inserts" - always list the columns you want to insert, in the order you want to insert them:
INSERT INTO MyTable (MyColumn1, MyCOlumns2) VALUES (@ValueForColumn1, @ValueForColumn2)
Second, you almost certainly shouldn't be inserting ID values, particularly if they are Row IDs: values which uniquely identify a row that otherwise may contain identical data. Never use the existing maximum and add one yourself - it causes intermittent problems that are a total PITA to fix.
Third, you need to specify a value for each of the parameters in your INSERT statement: my example above has two parameter values (the "@" prefix indicates a parameter value to SQL) so I would need two calls to
to supply them:
using (SqlConnection con = new SqlConnection(strConnect))
using (SqlCommand cmd = new SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con))
You only supply one in your example, but you tell it to expect 4 v alues.
Fourth, The parameter names must match up in the
call and the INSERT statement: you are missing the "@" prefix in your call.
Fifth, SQL uses commas as separators, not terminators:
is fine, but
is a syntax error as there is nothing between the final comma and the close bracket.