mpulla
unread,Apr 19, 2013, 5:15:22 PM4/19/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to publice...@googlegroups.com
Buenas tardes foxeros.
Tengo VFP 9.0 SP 2 y Sql Server 2012, la conexción la hago por ODBC (SQLNCLI10)
El código que expongo abajo, se ejecuta sin problemas pero al recuperar la data el campo
memo tiene una letra diferente, las palabras tiene espacios intermedios,
al querer manipular el string directamente tiene un comportamiento
raro, además al mandar a imprimir solo imprime el primer carácter, no tengo la menor idea de lo que puede estar pasando, espero que
alguien pueda ayudarme con el problema.
Saludos.
Mauricio
Tabla:
/****** Object: Table [dbo].[Prueba] Script Date: 19/04/2013 15:54:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Prueba](
[iKey] [int] NOT NULL,
[nota] [nvarchar](800) NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Prueba] ADD CONSTRAINT [DF_Prueba_nota] DEFAULT ('') FOR [nota]
GO
Store Procedure:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create PROCEDURE PrbIngreso_spI @xml xml
AS
SET NOCOUNT ON;
Begin Try
Insert into [dbo].[Prueba] (ikey, nota)
SELECT
y.Id.value('(ikey/text())[1]', 'int') As ikey,
isnull(y.Id.value('(nota/text())[1]', 'nvarchar(800)'), '') As Nota
FROM
@xml.nodes('/VFPData/rs') As y(Id);
End try
Begin Catch
;
Throw;
end Catch
GO
Código VFP:
CLOSE TABLES ALL
CREATE CURSOR rs (iKey Int, nota M)
LOCAL lcNota As String
lcNota = [Prueba de ingreso de datos con cursortoxml()] + CHR(10) + ;
[1.- Nota 1] + CHR(10) + ;
[1.- Nota 2] + CHR(10) + ;
[1.- Nota 3] + CHR(10) + ;
[1.- Nota 4] + CHR(10) + ;
[1.- Nota 5] + CHR(10) + ;
[1.- Nota 6]
INSERT INTO rs VALUES (1, lcNota)
INSERT INTO rs VALUES (2, '')
lcNota = [3.- Nota 1] + CHR(10) + ;
[3.- Nota 2] + CHR(10) + ;
[3.- Nota 3] + CHR(10)
INSERT INTO rs VALUES (3, lcNota)
LOCAL lcErrMsg As String, loException As Exception
PRIVATE lxml As String
CURSORTOXML('rs', 'lxml')
IF !_Screen.odBCTALK.odbcopen()
RETURN
ENDIF
TRY
IF SQLEXEC(_Screen.odBCTALK.iodbchandle, [Pruebas.dbo.PrbIngreso_spI ?lxml]) < 0
AERROR(laError)
Error laError(2)
ELSE
IF SQLEXEC(_Screen.odBCTALK.iodbchandle, [Select * From Pruebas.dbo.Prueba], 'rsdata') < 0
AERROR(laError)
Error laError(2)
ENDIF
ENDIF
CATCH TO loException
lcErrMsg = _Screen.odBCTALK.ErrorProcess(loException)
FINALLY
_Screen.odBCTALK.odbcclose()
ENDTRY
IF !EMPTY(lcErrMsg)
=MESSAGEBOX(lcErrMsg, 16, 'ERRORTITLE_LOC')
RETURN .F.
ENDIF
IF USED('rsdata')
SELECT rsdata
BROWSE
ENDIF