Retroceder   Foros del Web > Programación para sitios web > .NET

Respuesta
 
Herramientas Desplegado
Antiguo 16-sep-2004, 11:41   #1 (permalink)
CarlosAndres ha deshabilitado el karma
 
Avatar de CarlosAndres
 
Fecha de Ingreso: julio-2004
Ubicación: Bogotá, Colombia
Mensajes: 80
Enviar un mensaje por MSN a CarlosAndres
Generar un nuevo registro en una BD

Buenas:
Quiero insertar un nuevo registro en una base de datos de la siguiente forma:


OracleConnection oc = new OracleConnection();
oc.ConnectionString = @ConfigurationSettings.AppSettings["connectionString"];
oc.Open();
NwHistAdapter = new OracleDataAdapter("select * from SUBJECT_HISTORY us where us.SUBJECT_ID =" + strParent ,oc);
histCmdBuilder = new OracleCommandBuilder(NwHistAdapter);
histDataSet = new DataSet("histDataSet");
NwHistAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
NwHistAdapter.Fill(histDataSet, "SUBJECT_HISTORY");
DataRow dtrNewHist = histDataSet.Tables["SUBJECT_HISTORY"].NewRow();

dtrNewHist["SUBJECT_ID"]=strParent.ToString();
dtrNewHist["HISTORY_DATE"]=DateTime.Now;
dtrNewHist["DESCRIPTION"]=txtDescription.Text;
dtrNewHist["SUB_USER_ID"]=1;
dtrNewHist["LAST_CONTACT_DAY"]=txtLast.Text;
dtrNewHist["NEXT_ACTION_DATE"]=txtNext.Text;
dtrNewHist["ACTION_ID"]=txtNext_action.Text;
dtrNewHist["EFFECT_ID"]="24";
dtrNewHist["DURATION"]=12;
dtrNewHist["SUB_CONTACT_ID"]=strId;
dtrNewHist["SERVICE_ID"]=txtService.Text;

histDataSet.Tables["SUBJECT_HISTORY"].Rows.Add(dtrNewHist);
histDataSet.AcceptChanges();
NwHistAdapter.Update(histDataSet,"SUBJECT_HISTORY" );


Pero me aparece el siguiente error:
Server Error in '/EasySales' Application.
--------------------------------------------------------------------------------

ORA-02291: integrity constraint (ECMV2.SERVICE_CUSTOMER_HISTORY_FK1) violated - parent key not found
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Oracle.DataAccess.Client.OracleException: ORA-02291: integrity constraint (ECMV2.SERVICE_CUSTOMER_HISTORY_FK1) violated - parent key not found

Source Error:


Line 158: histDataSet.Tables["SUBJECT_HISTORY"].Rows.Add(dtrNewHist);
Line 159: //histDataSet.AcceptChanges();
Line 160: NwHistAdapter.Update(histDataSet,"SUBJECT_HISTORY" );
Line 161:
Line 162:


Source File: e:\easysales\easysales\wfnewhistory.aspx.cs Line: 160

Stack Trace:


[OracleException: ORA-02291: integrity constraint (ECMV2.SERVICE_CUSTOMER_HISTORY_FK1) violated - parent key not found]
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) +1667
Oracle.DataAccess.Client.OracleDataAdapter.Update( DataRow[] dataRows, DataTableMapping tableMapping) +9
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) +152
EasySales.WFSaveHistory.salvar(String strId, String strParent) in e:\easysales\easysales\wfnewhistory.aspx.cs:160
EasySales.WFSaveHistory.btnSave_Click(Object sender, EventArgs e) in e:\easysales\easysales\wfnewhistory.aspx.cs:97
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
Según lo que he leido tiene que ver con las llaves que estan contenidas en las otras tablas.

¿Me equivoco? , alguien puede ayudarme porfavor , aunque tenga que hacerlo on un INSERT INTO en vez del OracleCommandBuilder?

Última edición por CarlosAndres; 16-sep-2004 a las 11:47.
CarlosAndres está desconectado   Responder Citando
Respuesta

No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 03:02.
Políticas de Uso de Foros del Web


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96