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.

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.