XML 파일에서 SQL Server로 데이터를 업로드 할 수 있도록 업데이트하려고합니다. 그러나 다음 예외는 Must declare the scalar variable...
입니다. 나는 필요한 변수를 선언했다고 생각한다. 나는 약 10 번 체크했는데, 내가 잘못 본 곳을 볼 수는 없다. 너는 할수 있니? 대답이 '예'일 경우 내 코드 편집에 답안과 내가 잘못한 부분에 대한 설명을 제공해주십시오. 도와 주셔서 감사합니다.스칼라 변수는 어떻게 선언합니까?
sqltext="SET IDENTITY_INSERT HomeCareVisit ON update HomeCareVisit set [email protected],ScheduledDateTime= @ScheduledDateTime,[email protected], [email protected], [email protected],[email protected],[email protected],[email protected],[email protected],[email protected] where [email protected]";
SqlCommand Insertcommand = new SqlCommand(sqltext, conn);
//SqlCommand Insertcommand = new SqlCommand("SET IDENTITY_INSERT HomeCareVisit ON update HomeCareVisit set [email protected],ScheduledDateTime= @ScheduledDateTime,[email protected], [email protected], [email protected],[email protected],[email protected],[email protected],[email protected],[email protected] where [email protected]");
adpter.InsertCommand = Insertcommand;
adpter.InsertCommand.ExecuteNonQuery();
try
{
using (Insertcommand)
{
Insertcommand.Parameters.AddWithValue("@PatientNo", PatientNo);
Insertcommand.Parameters.AddWithValue("@FurtherVisitRequired", FurtherVisitRequired);
Insertcommand.Parameters.AddWithValue("@AdvisoryNotes", AdvisoryNotes);
Insertcommand.Parameters.AddWithValue("@Prescription", Prescription);
Insertcommand.Parameters.AddWithValue("@TreatmentProvided", TreatmentProvided);
Insertcommand.Parameters.AddWithValue("@ActualVisitDateTime",ActualVisitDateTime);
Insertcommand.Parameters.AddWithValue("@Priority", Priority);
Insertcommand.Parameters.AddWithValue("@ScheduledDateTime", ScheduledDateTime);
Insertcommand.Parameters.AddWithValue("@TreatmentInstructions", TreatmentInstructions);
Insertcommand.Parameters.AddWithValue("@MedicalStaffID", MedicalStaffID);
Insertcommand.ExecuteNonQuery();
MessageBox.Show("updated");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
conn.Close();
MessageBox.Show("Done .. ");
신고해야하는 스칼라 변수는 무엇입니까? – McKay
@PatientNo하지만 코드에서 볼 수 있듯이 내가 선언 한 첫 번째 코드입니다. –
@PatientNo 변수가 선언되지 않았다는 오류 메시지가 표시됩니까? – McKay