-1

挿入リストには、選択した値の数よりも多くの項目が含まれているようですが、それがどこにあるのかわかりません。観察によると、何かが欠けていない限り、それらは同じですか?

   public static DateTime CreateMedicationDispenseLocationHistory( int medicationDispenseID, int locationID, int staffID, DateTime date )
    {
        SqlConnection connection = new SqlConnection( Utilities.DBConnectionString() );
        connection.Open();

        CreateMedicationDispenseLocationHistory( medicationDispenseID, locationID, staffID, date, connection, null );

        connection.Close();
        connection.Dispose();

        return date;
    }

    public static DateTime CreateMedicationDispenseLocationHistory( int medicationDispenseID, int locationID, int staffID, DateTime date, SqlConnection connection, SqlTransaction transaction )
    {
        Locations location = new Locations();
        MedicationList medication = new MedicationList();
        StringBuilder sqlString = new StringBuilder();

        SqlCommand command;

        sqlString.Append("INSERT INTO [MedicationDispenseLocationHistory] (");
        sqlString.Append("MedicationDispenseID, " );
        sqlString.Append("LocationID, " );
        sqlString.Append("StaffID, " );
        sqlString.Append("DateTimeStamp" );
        sqlString.Append(") SELECT SCOPE_IDENTITY();");

        command = new SqlCommand( sqlString.ToString(), connection );
        if( ( transaction != null ) ) command.Transaction = transaction;

        command.Parameters.Add( "@MedicationDispenseID", SqlDbType.Int ).Value = medication.MedicationDispenseID;
        command.Parameters.Add( "@LocationID", SqlDbType.Int ).Value = location.LocationID;
        command.Parameters.Add( "@StaffID", SqlDbType.Int, 500 ).Value = Helper.GetValue( GlobalVariables.loggedInStaff.StaffID );
        command.Parameters.Add( "@DateTimeStamp", SqlDbType.DateTime ).Value = Helper.GetDBDateValue(DateTime.Now);
        //command.Parameters.Add("@stopDate", SqlDbType.DateTime).Value = Helper.GetValue(medicationDispense.StopDate);
        medication.MedicationDispenseID = Convert.ToInt32( command.ExecuteScalar() );

        return date;
    }
4

1 に答える 1