Can any body help my problem,While inserting data{ex:userid} through textbox to database it is automatically check the database table ,if the data {ex:userid} is already there it should display msg 'data already there enter new value'.if the data is already there it should insert ,how to get this one can anybody help
Thank you

Declare @UserId varchar(10)
Set @UserId = 'sknake'

Insert Into UserTable (UserId)
Select @UserId
Where Not Exists 
(
  Select * 
  From UserTable x 
  Where x.UserId = @UserId
)

Select @@ROWCOUNT As Result

If the @@ROWCOUNT returns 0 then data already exists and it wasn't inserted, if it is 1 then it was inserted. This is for MSSQL, it depends on your DB and is really a database question more than a C# question.

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.