[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

FoxPro Update Using CommandBuilder Error

Dan Zruna

12/9/2002 4:23:00 AM

I'm getting the following error, ERROR [22018] [Microsoft]
[ODBC Visual FoxPro Driver]Data type mismatch, when trying
to update a FoxPro database using the ODBC provider. Has
anyone gotten this to work??? Any suggestions would be
greatly appreciated.
Here is my code:
Dim da As New OdbcDataAdapter()
Dim ds As New DataSet()
Dim cn As New OdbcConnection()
Dim cb As New OdbcCommandBuilder()
cb.QuotePrefix = "["
cb.QuoteSuffix = "]"

cn.ConnectionString = _abra
cn.Open()

da = New OdbcDataAdapter("select * from hrpersnl",
cn)
cb = New OdbcCommandBuilder(da)
da.Fill(ds, "Employee")

'Add a record to the table.
Dim tbl As DataTable
tbl = ds.Tables("Employee")

Dim test As String =
cb.GetInsertCommand.CommandText

Dim dr As DataRow
dr = tbl.NewRow()
dr("p_aborig") = "N"
dr("p_abotype") = ""
dr("p_accumcur") = 0
dr("p_active") = ""
dr("p_allocby") = ""
dr("p_annual") = 0
dr("p_anychang") = CType(Now(), Date)

tbl.Rows.Add(dr)
da.Update(ds, "Employee")
cn.Close()
5 Answers

Cindy Winegarden

12/10/2002 1:49:00 AM

0

Dan Zruna <dzruna@verticalsolution.com> scribbled in
news:02db01c29f32$648e8c40$d5f82ecf@TK2MSFTNGXA12,
> I'm getting the following error, ERROR [22018] [Microsoft]
> [ODBC Visual FoxPro Driver]Data type mismatch, when trying
> to update a FoxPro database using the ODBC provider.
....
> dr("p_anychang") = CType(Now(), Date)

Dan, I don't work with .NET all that much but I'm suspicious of the date
value. In FoxPro and Visual FoxPro a date literal is written like
{12/09/2002}. Is that what you are sending across?

--

Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org http://cindywinegarden.ads...
http://msdn.microsoft.c... http://foxc...



Dan Zruna

12/10/2002 2:46:00 AM

0

Hi Cindy,

I thought the provider would take care of that. I tried
replacing the dates with "{" & Now() & "}" and it did not
work. Is this what you meant?

>-----Original Message-----
>Dan Zruna <dzruna@verticalsolution.com> scribbled in
>news:02db01c29f32$648e8c40$d5f82ecf@TK2MSFTNGXA12,
>> I'm getting the following error, ERROR [22018]
[Microsoft]
>> [ODBC Visual FoxPro Driver]Data type mismatch, when
trying
>> to update a FoxPro database using the ODBC provider.
>.....
>> dr("p_anychang") = CType(Now(), Date)
>
>Dan, I don't work with .NET all that much but I'm
suspicious of the date
>value. In FoxPro and Visual FoxPro a date literal is
written like
>{12/09/2002}. Is that what you are sending across?
>
>--
>
>Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
>cindy.winegarden@mvps.org
http://cindywinegarden.ads...
>http://msdn.microsoft.c... http://foxc...
>
>
>
>.
>

Cindy Winegarden

12/10/2002 3:30:00 PM

0

Dan Zruna <dzruna@verticalsolution.com> scribbled in
news:0a5001c29fed$e7b0bba0$8af82ecf@TK2MSFTNGXA03,
> I thought the provider would take care of that. I tried
> replacing the dates with "{" & Now() & "}" and it did not
> work. Is this what you meant?

Something like that but see if you can send that expression to a text file
or output window to verify. If Now() is a datetime it needs to be in the
format, {12/10/2002 09:30:42}.
--

Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org http://cindywinegarden.ads...
http://msdn.microsoft.c... http://foxc...



Dan Zruna

12/10/2002 7:07:00 PM

0

Nothing seems to work and the ODBC.net provider continues
to give the ambiguous "ERROR [22018] [Microsoft][ODBC
Visual FoxPro Driver]Data type mismatch." message. There
are 236 columns I'm dealing with so I don't see ever
getting this thing to work using ODBC.net. Any ideas?
>-----Original Message-----
>Dan Zruna <dzruna@verticalsolution.com> scribbled in
>news:0a5001c29fed$e7b0bba0$8af82ecf@TK2MSFTNGXA03,
>> I thought the provider would take care of that. I tried
>> replacing the dates with "{" & Now() & "}" and it did
not
>> work. Is this what you meant?
>
>Something like that but see if you can send that
expression to a text file
>or output window to verify. If Now() is a datetime it
needs to be in the
>format, {12/10/2002 09:30:42}.
>--
>
>Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
>cindy.winegarden@mvps.org
http://cindywinegarden.ads...
>http://msdn.microsoft.c... http://foxc...
>
>
>
>.
>

Bob Grommes

1/1/2003 2:09:00 PM

0

Actually, depending on how the provider is configured it may need to see the
ISO date format:

{^2002-12-10 09:30:42}

That is what the driver should send to the server as it is the preferred
date constant format in VFP since version 5. That format should work 100%
of the time and be culture independent.

I have no experience with the ODBC provider interacting with VFP, but it
*may* also be that on the client side you need to use the ODBC time stamp
format, which would then be reformatted before it gets sent to the server:

{ts '2002-12-10 09:30:42'}

You might want to create a small test program with a static INSERT statement
and see what date constant formats work correctly and then use SQLTrace or
turn logging on in the DSN to see what SQL is actually being sent from your
program that is failing. The comparison should be instructive.

One final thing ... if there are any stored procedures (or in VFP7, database
events) defined on the server, you may be getting a Data Type Mismatch error
due to bugs in that code running on the server.

--Bob

"Dan Zruna" <dzruna@verticalsolution.com> wrote in message
news:05ee01c2a077$11630690$89f82ecf@TK2MSFTNGXA01...
> Nothing seems to work and the ODBC.net provider continues
> to give the ambiguous "ERROR [22018] [Microsoft][ODBC
> Visual FoxPro Driver]Data type mismatch." message. There
> are 236 columns I'm dealing with so I don't see ever
> getting this thing to work using ODBC.net. Any ideas?
> >-----Original Message-----
> >Dan Zruna <dzruna@verticalsolution.com> scribbled in
> >news:0a5001c29fed$e7b0bba0$8af82ecf@TK2MSFTNGXA03,
> >> I thought the provider would take care of that. I tried
> >> replacing the dates with "{" & Now() & "}" and it did
> not
> >> work. Is this what you meant?
> >
> >Something like that but see if you can send that
> expression to a text file
> >or output window to verify. If Now() is a datetime it
> needs to be in the
> >format, {12/10/2002 09:30:42}.
> >--
> >
> >Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
> >cindy.winegarden@mvps.org
> http://cindywinegarden.ads...
> >http://msdn.microsoft.c... http://foxc...
> >
> >
> >
> >.
> >