1

I am working with MySQL in my .net web app with the help of MySQL connector 5.0.9.0. I am getting data from a web service and inserting it in local database. I only want to insert unique rows in my local database. I came to know that when an duplication occurs, MySQL returned an error code: 1062. All i want to know that how i could i get this code in a variable and check it against my condition like:

if(errorCode == "1062")
{
    Response.Write("Record already exists");
}

else
{
    // add the record to database
}

Thanx in advance

1 Answer 1

2

Have a look at MySqlException class members. There is a Number property - Gets a number that identifies the type of error.

MySqlException Class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.