aylin_sk

aylin_sk

  • NA
  • 87
  • 0

inserting data

Dec 8 2004 5:00 AM
Hi, I want to insert some data using a button into database, but i cant...why can it be??Or what should i do?? public bool addPatient (string patientName, string patientLastName, string patientSex, string patientTreatStartDate, string patientBirthdate, string patientParent, string patientPhone, string patientAddress1, string patientAddress2, string patientCountyId, string patientCityId, string patientZipCode, string patientGroup, string patientExplanation, string patientWeek, string patientPotential) { OracleConnection myConnection = new OracleConnection(myRegistry.getRegistryValue("connectionString")); OracleCommand myCommand = myConnection.CreateCommand(); myCommand.CommandText = "LPMS.PATIENTS_PKG.ADD_PATIENT"; myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add("p_patient_name", OracleType.VarChar, 20).Value = patientName; myCommand.Parameters.Add("p_patient_last_name", OracleType.VarChar, 20).Value = patientLastName; myCommand.Parameters.Add("p_patient_sex", OracleType.VarChar, 1).Value = patientSex; myCommand.Parameters.Add("p_patient_treat_start_date", OracleType.VarChar, 10).Value = patientTreatStartDate; myCommand.Parameters.Add("p_patient_birthdate", OracleType.VarChar, 10).Value = patientBirthdate; myCommand.Parameters.Add("p_patient_parent", OracleType.VarChar, 50).Value = patientParent; myCommand.Parameters.Add("p_patient_phone", OracleType.VarChar, 40).Value = patientPhone; myCommand.Parameters.Add("p_patient_address1", OracleType.VarChar, 50).Value = patientAddress1; myCommand.Parameters.Add("p_patient_address2", OracleType.VarChar, 50).Value = patientAddress2; if (patientCountyId.Equals("")) myCommand.Parameters.Add("p_patient_county_id", OracleType.Number).Value = DBNull.Value; else myCommand.Parameters.Add("p_patient_county_id", OracleType.Number).Value = Int32.Parse(patientCountyId); if (patientCityId.Equals("")) myCommand.Parameters.Add("p_patient_city_id", OracleType.Number).Value = DBNull.Value; else myCommand.Parameters.Add("p_patient_city_id", OracleType.Number).Value = Int32.Parse(patientCityId); myCommand.Parameters.Add("p_patient_zipcode", OracleType.VarChar, 5).Value = patientZipCode; myCommand.Parameters.Add("p_patient_group", OracleType.VarChar, 1).Value = patientGroup; myCommand.Parameters.Add("p_patient_explanation", OracleType.VarChar, 75).Value = patientExplanation; if (patientWeek.Equals("")) myCommand.Parameters.Add("p_patient_week", OracleType.Number).Value = DBNull.Value; else myCommand.Parameters.Add("p_patient_week", OracleType.Number).Value = Int32.Parse(patientWeek); myCommand.Parameters.Add("p_patient_potential", OracleType.VarChar, 1).Value = patientPotential; OracleDataAdapter adapter = new OracleDataAdapter(myCommand); try { myConnection.Open(); myCommand.ExecuteNonQuery(); myConnection.Close(); } catch (OracleException e) { string errorMessages = ""; errorMessages += "Message: " + e.Message + "\n" + "Source: " + e.Source + "\n"; System.Diagnostics.EventLog log = new System.Diagnostics.EventLog(); log.Source = "discoveryZone"; log.WriteEntry(errorMessages, System.Diagnostics.EventLogEntryType.Error, e.Code); myError.lastError = errorMessages; return(false); } return(true); }

Answers (2)