954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How do i insert code for showing erros in an application

hi all, i want the application to show error message if the searched object is not in the database or if the user is trying to insert the same value again plz suggest some code.

sana.khatib20
Newbie Poster
10 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
hi all, i want the application to show error message if the searched object is not in the database or if the user is trying to insert the same value again plz suggest some code.

Don't know what database you are using but

Dim mReader as SqlReader
Dim strSQL as String

strSQL = "Select count(*) from yourtable where Value = " & Value
Dim mCommand as new SqlCommand(mConn,strSQL)
result = cmd.ExecuteScalar
if result is nothing then 
'you have no results
end if
tonym001
Newbie Poster
11 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

u can load the data from the database into a data table during the form load event.
and then check the data in the data table one row at a time using loop

babbu
Posting Whiz in Training
208 posts since Jun 2009
Reputation Points: -1
Solved Threads: 23
 

sam logic can be used to check if the user is inserting some duplicate data.
u can also use try catch for this by setting the primary key in the data base

babbu
Posting Whiz in Training
208 posts since Jun 2009
Reputation Points: -1
Solved Threads: 23
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You