1

I've been racking my brain trying to figure out what this error means and how to fix it:

The column name is not valid. [ Node name (if any) = ,Column name = id ]

Here is the db schema:

Staff:

  • Id: int, not null, auto increment by 1, primary key
  • username: varchar, not null
  • name: varchar, not null

And here is the insertion script:

String Insertion = "INSERT INTO Staff ([username], [name])
                    VALUES (@username, @name)";

SqlCeCommand InsertStaff = new SqlCeCommand(Insertion, connect);
InsertStaff.Parameters.AddWithValue("@username", Username.Text);
InsertStaff.Parameters.AddWithValue("@name", Name.Text);

InsertStaff.ExecuteNonQuery();

I've even tried including the Id column with no luck:

String Insertion = "INSERT INTO Staff ([Id], [username], [name])
                    VALUES (NULL, @username, @name)";

SqlCeCommand InsertStaff = new SqlCeCommand(Insertion, connect);
InsertStaff.Parameters.AddWithValue("@username", Username.Text);
InsertStaff.Parameters.AddWithValue("@name", Name.Text);

InsertStaff.ExecuteNonQuery();

I have no idea what the issue is, it just keeps breaking. Any tips?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0