I have a form on my web page that I want posting to my database in the background upon submitting the form. Here is my code:
if (Validation.IsValid())
{
// Insert a new user into the database
var db = Database.Open("StarterSite");
// Check if user already exists
var user = db.QuerySingle("SELECT Email FROM UserProfile WHERE LOWER(Email) = LOWER(@0)", email);
if (user == null) {
// Insert email into the profile table
db.Execute("INSERT INTO UserProfile (Email) VALUES (@0)", email);
}
}
This is sample code and I'm trying to interpret it. What's baffling me is that is says VALUES (@0). However, when the form on this page is submitted, it still manages to post the inputted email address though the value says (@0) ?
Any clarity would be greatly appreciated!
Regards,
Josh
(P.S, I'm new to ASP.NET)
sqlyou can simply check if the user exist or not by applyinguniqueconstraint. Have a look at the link which gives you detailed information about how to insert records into the database . onlinebuff.com/…