私はデータベースにフォーム変数を入れようとしていますが、私はまだこれらのことで新しいものです。インターネットからランダムにコピーしたコードを学習しようとしています。 これはこれは、によって与えられた情報であり、私に問題'System.Data.SqlClient.SqlException'修正する方法? Visual Studio 2015
@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");
}
を与える唯一のものである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'.
そして、これはエラーが明らかに位置している。
db.Execute(insertCommand, Nome, Email, Tel, Adress, Gender);
私があれば謝罪私は言ったように、私はまだ非常に新鮮なasp.netであり、それはendevoursです、ばかな質問を投稿しています。
これを読んでいただきありがとうございます。うまくいけば助けてもらえますか?
EDIT: 私はThe database cannot be opened because it is version 782. This server supports version 706 and earlier. A downgrade path is not supported 上のソリューションを使用してみましたし、それらのどれも私のために働いていない、私はそれがないので、接続がすでに(LocalDB)\ MSSQLLocalDBあり、デフォルトでは、VS Communityエディション2015を使用していますここの問題。
それはWebMatrixの、彼ら[実際に自分のチュートリアルでビューにロジックを入れ奨励](だhttp://www.asp.net/web-pages/overview/data/5-working-with data)である。 MVCチュートリアルでは、ビューモデルとしてEntityモデルを使用しています。 – CodeCaster
答えをいただきありがとうございます。私はどのようにdatabseファイル形式をダウングレードするのですか?私はエラーを修正するために必要なSQL Serverのバージョンを知りませんので、ダウングレードはより安全なアプローチになると思います。 –
SQL Server Management Studioをインストールしている場合は、これを行うことができます。 –