Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21174

VB6: SQL statement returns no error for duplicate primary key

$
0
0
I use MS Access database. I have a primary key declared and MS Access throwing an error message box when I try to type in a record manually with primary key violation.

But the VB6 code catches no error when it attempts duplicate primary key entry. The transaction is however not successful. My code is as follows.

.....
On Error GoTo err_add
.....
sql_string = "INSERT INTO ......"
Form1.db.Execute (sql_string)
....
err_add: MsgBox "Duplication is prohibited.", vbCritical, "Error"


The Err.number value is zero and the message box never appears.

Please help.

Viewing all articles
Browse latest Browse all 21174

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>