Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
frens m jus a beginner, i have given the coding for inserting the values. now i want to know how to stop saving the existing data. can u pls send me the coding in vb.net.(user mustn't be able to save data which he has entered earlier)
Posted
Comments
Manoj K Bhoir 6-Dec-11 0:36am    
Please provide your code which you used to insert Data!

In stead of doing at VB level, you can easily perform at SQL level as:

SQL
INSERT INTO dbo.Applications (Date, firstname, lastname, Version) VALUES('3/12/2011', 'Tom', 'cruise', '2.0') WHERE NOT EXISTS (SELECT * FROM dbo.Applications WHERE firstname = Tom AND lastname = cruise)
 
Share this answer
 
Comments
jus coding 6-Dec-11 0:53am    
u mean to say that i have to write this in sql
Try this.

SQL
IF((SELECT COUNT(id) FROM Users WHERE username = @username) > 0)
BEGIN
   -- UPDATE STATEMENT
END
ELSE
BEGIN
   -- INSERT STATEMENT
END


Regards,
Eduard
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900