Ver Mensaje Individual
  #1  
Antiguo 10-05-2012
ErYcK ErYcK is offline
Miembro
NULL
 
Registrado: abr 2012
Posts: 26
Reputación: 0
ErYcK Va por buen camino
Dataset not in edit or insert mode

Buenas a todos, mi problema es el siguiente:
Trabajo con c++ Builder 6 y Access 2007
Mi aplicación se encarga de cargar un archivo .csv en un StringGrid mediante un boton al que llamo Importar, hasta ahi todo bien, una vez cargado este archivo, intento que los datos de este StringGrid se guarden en la base de datos que tengo en acces lo hago de la siguiente forma:

Código:
XDatos->TCategorias->Open();

        XDatos->TSubCat1->Open();

        XDatos->TSubCat2->Open();

        XDatos->TSubCat3->Open();

        XDatos->TMarcas->Open();


        XDatos->TCaracteristicas->Open();

        for (int f=1;f<=StringGrid1->RowCount;f++)
        {

                if (StringGrid1->Cells[0][f]!="")
                {

                        XDatos->QProductos->Append();
                        XDatos->QProductosREFERENCIA->Value = StringGrid1->Cells[0][f];
                        XDatos->QProductosESTADO->Value = StringGrid1->Cells[1][f];
                        //XDatos->QProductosCATEGORIA->Value = StringGrid1->Cells[2][f];
                        bool esta=false;
                        while(!XDatos->TCategorias->Eof)
                        {
                                if (StringGrid1->Cells[2][f] == XDatos->TCategoriasCATEGORIA->Value)
                                {
                                        XDatos->QProductosCATEGORIA->Value=XDatos->TCategoriasCodCategoria->Value;
                                        esta=true;
                                }
                                XDatos->TCategorias->Next();
                        }
                        if (!esta)
                        {
                                XDatos->TCategorias->Append();
                                XDatos->TCategoriasCATEGORIA->Value = StringGrid1->Cells[2][f];
                                XDatos->QProductosCATEGORIA->Value=XDatos->TCategoriasCodCategoria->Value;
                                XDatos->TCategorias->Post();

                        }
                        //XDatos->QProductosSUBCAT1->Value = StringGrid1->Cells[3][f];
                        esta=false;
                        while(!XDatos->TSubCat1->Eof)
                        {
                                if (XDatos->TSubCat1CATEGORIA->Value == XDatos->QProductosCATEGORIA->Value && XDatos->TSubCat1SUBCAT1->Value == StringGrid1->Cells[3][f])
                                {
                                        XDatos->QProductosSUBCAT1->Value= XDatos->TSubCat1CodSUBCAT1->Value;
                                        esta=true;
                                }
                                XDatos->TSubCat1->Next();
                        }
                        if (!esta)
                        {


                                //XDatos->TSubCat1CodSUBCAT1->Value = XDatos->QProductosSUBCAT1->Value;
                                XDatos->TSubCat1->Append();
                                XDatos->TSubCat1SUBCAT1->Value = StringGrid1->Cells[3][f];
                                XDatos->TSubCat1CATEGORIA->Value = XDatos->QProductosCATEGORIA->Value;
                                XDatos->QProductosSUBCAT1->Value= XDatos->TSubCat1CodSUBCAT1->Value;
                                XDatos->TSubCat1->Post();

                        }
                        //XDatos->QProductosSUBCAT2->Value = StringGrid1->Cells[4][f];
                        esta=false;
                        while(!XDatos->TSubCat2->Eof)
                        {
                                if (XDatos->TSubCat2SUBCAT1->Value == XDatos->QProductosSUBCAT1->Value && XDatos->TSubCat2SUBCAT2->Value == StringGrid1->Cells[4][f])
                                {
                                        XDatos->QProductosSUBCAT2->Value = XDatos->TSubCat2CodSUBCAT2->Value;
                                        esta=true;
                                }
                                XDatos->TSubCat2->Next();
                        }
                        if (!esta)
                        {


                                //XDatos->TSubCat2CodSUBCAT2->Value = XDatos->QProductosSUBCAT2->Value;
                                XDatos->TSubCat2->Append();
                                XDatos->TSubCat2SUBCAT2->Value = StringGrid1->Cells[4][f];
                                XDatos->TSubCat2SUBCAT1->Value = XDatos->QProductosSUBCAT1->Value;
                                XDatos->QProductosSUBCAT2->Value = XDatos->TSubCat2CodSUBCAT2->Value;
                                XDatos->TSubCat2->Post();
                        }
                        //XDatos->QProductosSUBCAT3->Value = StringGrid1->Cells[5][f];
                        esta=false;
                        while(!XDatos->TSubCat3->Eof)
                        {
                                if (XDatos->TSubCat3SUBCAT2->Value == XDatos->QProductosSUBCAT2->Value && XDatos->TSubCat3SUBCAT3->Value == StringGrid1->Cells[5][f])
                                {
                                        XDatos->QProductosSUBCAT3->Value = XDatos->TSubCat3CodSUBCAT3->Value;
                                        esta=true;
                                }
                                XDatos->TSubCat3->Next();
                        }
                        if (!esta)
                        {


                                //XDatos->TSubCat3CodSUBCAT3->Value = XDatos->QProductosSUBCAT3->Value;
                                XDatos->TSubCat3->Append();
                                XDatos->TSubCat3SUBCAT3->Value = StringGrid1->Cells[5][f];
                                XDatos->TSubCat3SUBCAT2->Value = XDatos->QProductosSUBCAT2->Value;
                                XDatos->QProductosSUBCAT3->Value = XDatos->TSubCat3CodSUBCAT3->Value;
                                XDatos->TSubCat3->Post();
                        }
                        XDatos->QProductosPRODUCTO->Value = StringGrid1->Cells[6][f];
                        XDatos->QProductosKEY->Value = StringGrid1->Cells[7][f];
                        XDatos->QProductosMARCA->Value = StringGrid1->Cells[8][f];
                        esta=false;
                        while(!XDatos->TMarcas->Eof)
                        {
                                if (XDatos->TMarcasMARCA->Value == XDatos->QProductosMARCA->Value)
                                        esta=true;
                                XDatos->TMarcas->Next();
                        }
                        if (!esta)
                        {
                                XDatos->TMarcas->Append();
                                XDatos->TMarcasMARCA->Value = XDatos->QProductosMARCA->Value;
                                XDatos->TMarcas->Post();
                        }
                        XDatos->QProductosDESCRIPCION->Value = StringGrid1->Cells[9][f];
                        XDatos->QProductosCATEGORIAX->Value = StringGrid1->Cells[10][f];
                        XDatos->QProductosCATEGORIAS->Value = StringGrid1->Cells[11][f];
                        XDatos->QProductos->Post();
                        for(int c=12;c<=StringGrid1->ColCount;c++)
                        {
                                if (StringGrid1->Cells[c][f]!="")
                                {
                                        XDatos->TCaracteristicas->Append();
                                        XDatos->TCaracteristicasLuCATEGORIA->Value = StringGrid1->Cells[2][f];
                                        XDatos->TCaracteristicasLuSUBCAT1->Value = StringGrid1->Cells[3][f];
                                        XDatos->TCaracteristicasLuSUBCAT2->Value = StringGrid1->Cells[4][f];
                                        XDatos->TCaracteristicasLuSUBCAT3->Value = StringGrid1->Cells[5][f];
                                        XDatos->TCaracteristicasref->Value = StringGrid1->Cells[0][f];
                                        if (c % 2 ==0)
                                                XDatos->TCaracteristicasCARACTERISTICA->Value = StringGrid1->Cells[c][f];
                                        else
                                                XDatos->TCaracteristicasVALOR->Value = StringGrid1->Cells[c][f];

                                        XDatos->TCaracteristicas->Post();
                                }
                        }
                }
        }
Compilar compila bien, el problema es que cuando le doy a importar, me salta el error diciéndome que el dataset no esta en edit o insert mode lo cual no entiendo, ya que antes de asignarle valores pongo el
XDatos->TCategoria->Append();.

Espero que haya quedado claro el problema, si alguien tiene alguna idea sobre que puede pasar, o a alguien le ha pasado algo parecido agradecería la ayuda.

Gracias de ante mano.
Responder Con Cita