USED: C #, Access
HAVE:
In Access, by means of the code, records are added to the database with a specific ID. How to check the unique ID of the added record?
Those. if there is an entry with the ID present in the database, then we do not add it, if not, add it. If I understand correctly, will it be a long cycle?
To add a record using the following code.
string connStringAcc = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", textBox2.Text); using (OleDbConnection connAcc = new OleDbConnection(connStringAcc)) { connAcc.Open(); // добавим строку в таблицу hist OleDbCommand command = new OleDbCommand("INSERT INTO hist(url) VALUES('" + textBox5.Text + "')", connAcc); command.ExecuteNonQuery(); } QUESTION
1. How to check the unique ID of the added record?
UNIQUE), then you can simply add and everything that is not unique will not be added. I really judge by mysql, but IMHO in access should also work. - Solid'ALTER TABLE hist ADD UNIQUE (id)'. Well, the query itself to change:INSERT INTO hist(id, url) VALUES('" + someid + "', '" + textBox5.Text + "')"- Solid