At the moment I'm learing Databases. this is some code that I'm using.
The question that I have is, can I insert a row without ID.
I mean that the database increase the ID number itself.

Thanks in advance.

command = new OleDbCommand();
            command.Connection = connect;
            command.CommandText = "INSERT INTO Calendar (ID, Datum, Titel, Opmerking) VALUES (@ParaID, @ParaDatum, @ParaTitel, @Opmerking)";
            command.Parameters.AddWithValue("@ParaID","ID" );
            command.Parameters.AddWithValue("@ParaDatum", Calendar1.SelectedDate.Date.ToShortDateString());
            command.Parameters.AddWithValue("@ParaTitel", "dit is een test");
            command.Parameters.AddWithValue("@Opmerking", "dit is ook een test");

Recommended Answers

All 2 Replies

Yes. If omitted from the INSERT, an auto increment column (MySQL) or identity column (MSSQL) will do the rest. Passing the ID as NULL is also possible.

I will try it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.