0
protected void ButtonNota_Click(object sender, EventArgs e)
{
string nota = TextBoxNota.Text;
string materieID = ddl.SelectedValue.ToString();
string userID = Session["userID"].ToString();
SqlConnection conn = new SqlConnection("Data Source=localhost\\sqlexpress;Initial Catalog=UsersDB;Integrated Security=SSPI");
try
{
DataTable dt = new DataTable();
conn.Open();
using (SqlCommand command = new SqlCommand("insertIntoNote", conn))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@notaMaterie",System.Data.SqlDbType.Int);
command.Parameters["@notaMaterie"].Value =Convert.ToInt32(TextBoxNota.Text);
command.Parameters.Add("@idMaterie", System.Data.SqlDbType.Int);
command.Parameters["@idMaterie"].Value = Convert.ToInt32(materieID);
command.Parameters.Add("@userID", System.Data.SqlDbType.Int);
command.Parameters["@userID"].Value = Convert.ToInt32(userID);
command.ExecuteNonQuery();
}
conn.Close();
}
catch (Exception ex)
{
// Handle the error
}
}
} 저장 사용삽입 데이터 절차
저장 프로 시저 코드 :
CREATE PROCEDURE [dbo].[instertIntoNote]
@notaMaterie int,
@idMaterie int,
@userID int
AS
BEGIN
INSERT into Note (UserID,MaterieID,Nota) values (@userID,@idMaterie,@notaMaterie)
END
되지 않는 이유는 무엇 T의 IT WORK?
/////
LE : 그래서 데이터베이스에 내가 원한 성적을 삽입하는 데 성공하지만 지금은 다른 문제가 있습니다. 사용자 ID와 등급 iserted는 정확하지만 subjectID does t t chage (나는 수학, 스포츠, 영어를 가지고 있으므로 1, 2, 3이라고 말할 것입니다 ... 드롭 다운에서 어떤 주제를 선택하든 sublectID는 1과 같습니다 ... 수학을 위해)
프로그램이 처음에는 작동하지 않는 경향이 있습니다 ... 디버그를합니까? 오류가 무엇입니까? – Aristos
그것이 의미하는 바가 효과가 없다는 것을 설명하십시오. 오류가 있습니까? 예상치 못한 동작입니까? –
처음에는 저장 프로 시저'instertIntoNote'의 이름이 프로그램'insertIntoNote'에서 호출 된 이름과 다릅니다. 그러나 또 다시, 당신은 당신이 얻는 오류와 우리가 당신을 도울 수있는 곳을 게시 할 필요가 있습니다. – GVashist