Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

When the record of database is unique and user adds a duplicated value in it, in error handling how can I notice the user. (I mean the error must have a id or sth like that..)

}
		catch (Exception e01)
		{
			Label3.Text=e01.Message.ToString();				
		}

:rolleyes:

Thanks

Posted

if you do a Try Catch block, like

 

Try

'some SQL insert statement

Catch ex as Exception

'ex.Message has the error message.. you could just look for certain text here (depends on the database though)

End Try

If you make it idiot proof, they'll build a better idiot :-)
  • Administrators
Posted
What database are you using? If it is SQL then you are much better trying to catch a SqlException - this will allow you to check the SQL error code. If you are using access then check for a OleDbException this at least gives you an ErrorCode property.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

1-

depends on the database though
would you please show me a code?

 

2-I use msSql2000

If it is SQL then you are much better trying to catch a SqlException - this will allow you to check the SQL error code
!

I know the theory i need code!!!:)

Posted

oh Thanks like this:

 

//Label6.Text = e01.Number.ToString();

if (e01.Number == 2627)

{

Label6.Text = "Sorry there is a username with the same what u typed!Please try new username";

}

 

:)

//handle duplicate id here

if there were many errors what should I do then?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...