dropdownlist
と私のtextbox
の値をデータベースストアドプロシージャに挿入したいのですが、挿入されず、エラーも出ません。私が間違っていることは何ですか?私のDBにデータを送ることができません
protected void btnPlaceScores_Click(object sender, EventArgs e)
{
string conn = WebConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
using (SqlConnection myconnection = new SqlConnection(conn))
{
SqlCommand cmd = new SqlCommand("MatchScores", myconnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("HomeTeam", drop1.SelectedItem.Value);
cmd.Parameters.AddWithValue("AwayTeam", drop2.SelectedItem.Value);
cmd.Parameters.AddWithValue("Scores", txtScores.Text);
try
{
myconnection.Open();
cmd.ExecuteNonQuery();
}
catch { }
finally
{
myconnection.Close();
}
}
}
は、Microsoft SQLを使用している場合は、通常のパラメータが「@」で始まることを確認手動で接続を閉じる必要があります。ステートメントを使用すると、あなたのためにそれを行います)。 –
あなたがやっていることを '使っている 'ことがすでに終わっているので、' try catch catch'を削除してください。 –
エラーは何ですか? –