Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #13311 > unrolled thread
| Started by | Carlos Vazquez <frinchis@gmail.com> |
|---|---|
| First post | 2021-05-19 05:40 -0700 |
| Last post | 2023-10-31 11:42 -0700 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
Vo2Ado Empty dates Carlos Vazquez <frinchis@gmail.com> - 2021-05-19 05:40 -0700
Re: Vo2Ado Empty dates Phil McGuinness <sherlocksoftware@gmail.com> - 2021-05-21 07:15 -0700
Re: Vo2Ado Empty dates Carlos Vazquez <frinchis@gmail.com> - 2021-05-22 04:37 -0700
Re: Vo2Ado Empty dates Jamal <nospam@example.com> - 2021-05-22 12:42 -0400
Re: Vo2Ado Empty dates Carlos Vazquez <frinchis@gmail.com> - 2023-10-31 11:42 -0700
| From | Carlos Vazquez <frinchis@gmail.com> |
|---|---|
| Date | 2021-05-19 05:40 -0700 |
| Subject | Vo2Ado Empty dates |
| Message-ID | <b068bd7d-14db-46d7-a927-43c69640f2a6n@googlegroups.com> |
Hi! I'm converting some DBF table to SQLServer. When there is an empty date value, the following code throws an error "type conflict: text is not compatible with date". How can I pass empty date values to SQLServer? Thanks!! **************** aParametros := ArrayCreate(2) oCmd:CommandText := "INSERT INTO [Ark].[dbo].[Cliente] ( [Ark].[dbo].[Cliente].[Codigo], [Ark].[dbo].[Cliente].[Fecha] ) VALUES (?,?)" sCliente:GoTop() WHILE !sCliente:EoF aParametros[ 1] := sCliente:FIELDGET( #CODIGO ) aParametros[ 2] := sCliente:FIELDGET( #FECHA ) // oCmd:Execute(@uResult,aParametros,NIL) IF uResult != 1 MostrarError( oCmd:Error:description ) BREAK ENDIF sCliente:Skip() ENDDO
[toc] | [next] | [standalone]
| From | Phil McGuinness <sherlocksoftware@gmail.com> |
|---|---|
| Date | 2021-05-21 07:15 -0700 |
| Message-ID | <d492233a-1e02-4fb0-b47e-f263f6725673n@googlegroups.com> |
| In reply to | #13311 |
On Wednesday, May 19, 2021 at 10:40:10 PM UTC+10, Carlos Vazquez wrote: > Hi! > I'm converting some DBF table to SQLServer. When there is an empty date value, the following code throws an error "type conflict: text is not compatible with date". > > How can I pass empty date values to SQLServer? FUNCTION dtosSQL( dDate AS USUAL ) AS STRING LOCAL cDate AS STRING IF IsString(dDate) .OR. dDate = NULL_DATE cDate := [null] ELSE cDate := ['] + Stuff(Stuff(DToS(dDate),5,0,[-]),8,0,[-]) + ['] // 20071201 return "2007-12-01" ENDIF // RETURN cDate
[toc] | [prev] | [next] | [standalone]
| From | Carlos Vazquez <frinchis@gmail.com> |
|---|---|
| Date | 2021-05-22 04:37 -0700 |
| Message-ID | <961d4f8b-1ce6-4e21-a4e4-63db183f19adn@googlegroups.com> |
| In reply to | #13314 |
El viernes, 21 de mayo de 2021 a las 16:16:00 UTC+2, Phil McGuinness escribió: > FUNCTION dtosSQL( dDate AS USUAL ) AS STRING > > LOCAL cDate AS STRING > > IF IsString(dDate) .OR. dDate = NULL_DATE > cDate := [null] > ELSE > cDate := ['] + Stuff(Stuff(DToS(dDate),5,0,[-]),8,0,[-]) + ['] // 20071201 return "2007-12-01" > ENDIF > // > RETURN cDate Phil, that function returns a string. I've tried to use that concept but then i get "error converting string to date". I've tried also to return NIL, NULL, NULL_DATE... to no avail. The only thing that works is returning a valid date, say CToD( '01/01/1900' )
[toc] | [prev] | [next] | [standalone]
| From | Jamal <nospam@example.com> |
|---|---|
| Date | 2021-05-22 12:42 -0400 |
| Message-ID | <s8bc93$1p6$1@dont-email.me> |
| In reply to | #13311 |
In your app, try calling AdoConvertNullStringToNull ( TRUE ) P.S. I don't use the Vo2Ado, but I looked at the documentation. Source: FUNCTION AdoConvertNullStringToNull ( lSet ) AS Argument(s) lSet When TRUE, NULL_STRINGS will be converted to NULL, else an Empty value is passed to COM. The default behaviour is NOT to convert them to NULL Return The process of converting NULL_STRINGS can be switched ON/OFF by calling the AdoCheckNullString function See Also Support functions, AdoCheckNullString, Data Types HTH, Jamal On 5/19/2021 8:40 AM, Carlos Vazquez wrote: > Hi! > I'm converting some DBF table to SQLServer. When there is an empty date value, the following code throws an error "type conflict: text is not compatible with date". > > How can I pass empty date values to SQLServer? > > Thanks!! > **************** > > aParametros := ArrayCreate(2) > > oCmd:CommandText := "INSERT INTO [Ark].[dbo].[Cliente] ( [Ark].[dbo].[Cliente].[Codigo], [Ark].[dbo].[Cliente].[Fecha] ) VALUES (?,?)" > > sCliente:GoTop() > WHILE !sCliente:EoF > aParametros[ 1] := sCliente:FIELDGET( #CODIGO ) > aParametros[ 2] := sCliente:FIELDGET( #FECHA ) > // > oCmd:Execute(@uResult,aParametros,NIL) > IF uResult != 1 > MostrarError( oCmd:Error:description ) > BREAK > ENDIF > sCliente:Skip() > ENDDO >
[toc] | [prev] | [next] | [standalone]
| From | Carlos Vazquez <frinchis@gmail.com> |
|---|---|
| Date | 2023-10-31 11:42 -0700 |
| Message-ID | <8e08b5f7-500f-45ea-bb89-0beb90591229n@googlegroups.com> |
| In reply to | #13317 |
Jamal, sorry for ultra-late response... :) I was (again) looking for an answer to "How to send NULL values to SQL servers" and see this message. Your anwser is the one I needed. Thx!!! El sábado, 22 de mayo de 2021 a las 18:42:13 UTC+2, Jamal escribió: > In your app, try calling > > AdoConvertNullStringToNull ( TRUE ) > > > P.S. I don't use the Vo2Ado, but I looked at the documentation. Source: > > > FUNCTION AdoConvertNullStringToNull ( lSet ) AS > > Argument(s) > > lSet When TRUE, NULL_STRINGS will be converted to NULL, else an Empty > value is passed to COM. The default behaviour is NOT to convert them to NULL > > > Return > > > The process of converting NULL_STRINGS can be switched ON/OFF by calling > the AdoCheckNullString function > > > See Also > > Support functions, AdoCheckNullString, Data Types > > > HTH, > Jamal > On 5/19/2021 8:40 AM, Carlos Vazquez wrote: > > Hi! > > I'm converting some DBF table to SQLServer. When there is an empty date value, the following code throws an error "type conflict: text is not compatible with date". > > > > How can I pass empty date values to SQLServer? > > > > Thanks!! > > **************** > > > > aParametros := ArrayCreate(2) > > > > oCmd:CommandText := "INSERT INTO [Ark].[dbo].[Cliente] ( [Ark].[dbo].[Cliente].[Codigo], [Ark].[dbo].[Cliente].[Fecha] ) VALUES (?,?)" > > > > sCliente:GoTop() > > WHILE !sCliente:EoF > > aParametros[ 1] := sCliente:FIELDGET( #CODIGO ) > > aParametros[ 2] := sCliente:FIELDGET( #FECHA ) > > // > > oCmd:Execute(@uResult,aParametros,NIL) > > IF uResult != 1 > > MostrarError( oCmd:Error:description ) > > BREAK > > ENDIF > > sCliente:Skip() > > ENDDO > >
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web