I'm trying to put form variables into a database, however, I'm still VERY new at these things and I'm just trying random copy pasted code from the internet to learn. This is the only thing giving me problems
@using WebMatrix.Data;
@using WebMatrix.WebData;
@using System.Data.SqlClient;
@{
ViewBag.Title = "Recruta";
}
@{
var Nome = "";
var Email = "";
var Tel = "";
var Adress = "";
var Gender = "";
Nome = Request.Form["Nome"];
Email = Request.Form["Email"];
Tel = Request.Form["Tel"];
Adress = Request.Form["Adress"];
Gender = Request.Form["Gender"];
var db = Database.Open("Usuarios");
var insertCommand = "INSERT INTO Usuarios (Nome, Email, Tel, Adress, Gender) Values(@0, @1, @2, @3, @4)";
db.Execute(insertCommand, Nome, Email, Tel, Adress, Gender);
Response.Redirect("~/Usuarios");
}
This is the information given by vs:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: The database 'c:\users\softinsa\documents\visual studio 2015\Projects\Best_prototype_01\Best_prototype_01\App_Data\Usuarios.mdf' cannot be opened because it is version 851. This server supports version 706 and earlier. A downgrade path is not supported.
Cannot attach the file 'c:\users\softinsa\documents\visual studio 2015\Projects\Best_prototype_01\Best_prototype_01\App_Data\Usuarios.mdf' as database 'c:\users\softinsa\documents\visual studio 2015\Projects\Best_prototype_01\Best_prototype_01\App_Data\Usuarios.mdf'.
And this is where the error lies apparently:
db.Execute(insertCommand, Nome, Email, Tel, Adress, Gender);
I apologize if I'm posting a dumb question, as I said, I'm still very fresh in asp.net and it's endevours.
I appreciate you reading this and hopefully you can help.
EDIT: I tried using the solutions on The database cannot be opened because it is version 782. This server supports version 706 and earlier. A downgrade path is not supported and none of them worked for me, I'm using VS Community edition 2015, by default the connections are already (LocalDB)\MSSQLLocalDB so that isn't the issue here.