I am working on my project on WebMatrix and SQL Server database. At the moment I have achieved the following:
- Created a webpages (i.e. Login Page, Sign Up/Register page for the website
- Created a database
- Created the connection to the database using:
WebSecurity.InitializeDatabaseConnection("cinema","Customer","Customer_ID","Email",true);
within the the _AppStart.cshtml file.
Now my problem is after doing all of this, and trying to use the existing data
found in the Customer table to select the attributes to validate the login details entered
in the webpage input form, it comes up with an error saying
Invalid column name 'UserId'.
System.Data.SqlClient.SqlException: Invalid column name 'UserId'.
The code I used was:
vardb=Database.Open("cinema");varselectQueryString="SELECT * FROM Customer";// Initialize general page variablesvarEmail="";varPassword="";if(IsPost){{Email=Request.Form["Email"];Password=Request.Form["Password"];//rememberMe = Request.Form["rememberMe"].AsBool();// Attempt to log in using provided credentialsif(WebSecurity.Login(Email,Password,false)){Response.Redirect("~/Default");}else{ModelState.AddFormError("The user name or password provided is incorrect.");}}}It did not seem to like this either.
<labelfor="Email"@if(!ModelState.IsValidField("Email")){<text>class="error-label"</text>}>Email address</label>
<inputtype="Email"id="Email"name="Email"value="@Email"@Validation.For("Email")/>@* Write any user name validation errors to the page *@
@Html.ValidationMessage("Email")
I have no idea what do now. I have tried researching online and in books but nothing seems to work.I hope someone can help me now as my project is due in on Monday 31st March so in a few days.