データベースにデータを送信するためにコードを実行すると、データベースへの接続文字列は正しいです。私は私のログインのためにそれをテストしました。データベースエラー:「ストアドプロシージャ 'sp_insert」が見つかりません
私はこのエラーを取得する:
Could not find stored procedure 'sp_insert'
SqlConnection con = new SqlConnection(@"Data Source = (IP); Persist Security Info = True; User ID = sa; Password = 1234");
SqlCommand cmd = new SqlCommand("sp_insert", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("username", textBox1.Text);
cmd.Parameters.AddWithValue("password", textBox2.Text);
cmd.Parameters.AddWithValue("email", textBox4.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
方法? – galister
プロシージャ 'sp_insert'が実際に存在する場合、おそらくデータベースを明示的に指定する必要があります。 'SqlCommand cmd = new SqlCommand(" DatabaseName.schemaName.sp_insert "、con);' –
[プロシージャ名の前に "sp_"を付けないでください(https://sqlperformance.com/2012/10/t-sql -queries/sp_prefix)を実行します。これは、システムストアドプロシージャ用に予約されています。それを自分で使用すると、将来的に問題が発生する可能性があり、起動するためのパフォーマンス上の問題があります。 –