Visual Studioでクラスにストアドプロシージャを呼び出しますデータを検索し、最後にsp_viewというSQLサーバにデータを表示すると、 のようになります。私はストアドプロシージャをテストし、それは正常に実行されました。今私は既にデータベースに接続しているVs2015に私はそれが成功したテスト接続をクリックするまで今すぐ接続されたUkをクリックします。今、私たちは私のVS2015のC#でWindowsフォームのUI上にある私は、単純なストアドプロシージャにそのデータを削除します<strong>sp_delete</strong>データを更新してしまうデータと<strong>sp_Update</strong>を挿入する<strong>sp_insert</strong>を書き、<strong>sp_search</strong>その
。これらのように見えます。私はクラスを作成しました私は私のプロジェクトのソリューションエクスプローラでリポジトリという名前を付けました。これらのクラスはここにコードがあります ここにあります。私の問題は私は4つのストアドプロシージャをsp_insert、sp_Update、sp_delete 、sp_search、私のクラスのsp_viewとshow.isには何も私のコードに関する問題はありません。
public class repositories
{
//Initializes a new instance of the DataContext class by referencing the connection name of database.
public static DataClasses1DataContext db = null;
//that registration is my table
public static void add(registration)
{
db = new DataClasses1DataContext();
//they are getting red cannot call sp_insert that i was created in sql server in my whole entire procedure.
db.sp_insert(Username, password, securityQuestion, SecurityAnswer, LastName, firstName, MiddleInitial, address, gender, birthdate, age);
}
public static void Update (registration)
{
db = new DataClasses1DataContext();
db.sp_Update(Username, password, securityQuestion, SecurityAnswer, LastName, firstName, MiddleInitial, address, gender, birthdate, age);
}
public static void delete (registration)
{
db = new DataClasses1DataContext();
db.sp_Delete(UserId);
}
public static List<sp_ViewResult> View()
{
db = new DataClasses1DataContext();
List<sp_ViewResult> View() = db.sp_view().Tolist<sp_viewResult>();
}
}
}
私はそうする際にいくつかのガイダンスが必要です。誰でも私を助けることができます..
あなたの助けに感謝します。
Proの先端を使用する:(https://msdn.microsoft.com/en-us/library/dd172115(V = VS.100).aspxの[ 'sp_'接頭辞を使用しないでください]を)。 –
'DataClasses1DataContext'のコードはどこから来たのですか?あなたはそれを書きましたか?それはEFから生成されましたか? –
@Jhon Wuはコメントをお寄せいただきありがとうございますが、なぜsp_がストアドプロシージャとしてSQL Serverから作成されたのですか? – Sharkweb