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.

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by babbu
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
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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.