Inserting into a table, how to insert a auto incrementing ID

I am trying to insert data into a SQL table but getting an error that I do not have the required number of columns, e.g. I only give it teamname and teamtag, when it also had ID in the SQL table. The ID auto increments though so I am not sure how to make this work, any help is appreciated.

private void btnAdd_Click(object sender, EventArgs e)
{
    da.InsertCommand = new SqlCommand("INSERT INTO tblTeams VALUES(@TEAMNAME, @TEAMTAG)", cs);
    da.InsertCommand.Parameters.Add("@TEAMNAME", SqlDbType.VarChar).Value = txtTeamName.Text;
    da.InsertCommand.Parameters.Add("@TEAMTAG", SqlDbType.VarChar).Value = txtTeamTag.Text;

    cs.Open();
    da.InsertCommand.ExecuteNonQuery();
    cs.Close();
}

Error:

Column name or number of supplied values does not match table definition.

Answers


Specify the columns you are populating.

INSERT INTO tblTeams (TeamName, TeamTag) VALUES(@TEAMNAME, @TEAMTAG)

Need Your Help

Create new page in Webtop

documentum webtop

How do I create a new webpage in the Documentum front end Webtop?