Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 2nd, 2004, 06:22 AM
Registered User
 
Join Date: Sep 2004
Location: Firenze, , Italy.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting record in Visual foxpro

I'm new here and I'm sorry about my english!!

I'm triyng to insert a record in a foxpro table using VFPOLEDB. All it's ok.
The problem appear when the record contain a field defined as date. In this case I obtain a message data type mismatch also if i insert a non null value in the date.
I tried to change the format of the date in many different way but i always obtain the same message.
Here is the code:

    Dim Conn As ADODB.Connection
    Dim Tbcli As ADODB.Recordset

    Dim Wdata As Date
    Dim Codice As String
    Dim Valuta_cont As Integer
    Dim Sw_find As Boolean
    Dim Strsql As String
    Dim Strconn As String

    If Swadh = 1 Then
        Set Conn = New ADODB.Connection
        Strconn = "Provider=vfpoledb.1;Data Source='" & Dir_adhoc(Sct) & "\'"
        Conn.CursorLocation = adUseClient
        Conn.Mode = adModeReadWrite
        Conn.Open Strconn
        Codice = Right(("000000" & Me![Acf_cdclfo]), 6)
        Strsql = "select * from CLI_ENTI where CLCODCLI= '" & "0" & Codice & "'"
        Set Tbcli = New ADODB.Recordset
        Tbcli.Open Strsql, Conn, adOpenDynamic, adLockOptimistic
        If Tbcli.BOF Then
            Wdata = Now()
            Tbcli.Close
            Set Tbcli = New ADODB.Recordset
            Strsql = "Insert into CLI_ENTI (CLCODCLI, CLRAGSOC, CLRAGSO2, CLINDIRI, CL___CAP, CLLOCALI, CLPROVIN, CLNAZION, cltelefo, cltelfax, clnumcel, clperfis, cl_sesso, cldatnas) VALUES ('" & Codice & "', '', '', '', '', '', '', '', '', '', '', '', '', " & Format(Wdata, "dd-mm-yyyy") & ")"
            Tbcli.Open Strsql, Conn, adOpenDynamic, adLockBatchOptimistic, adCmdText

May somebody help me??
Thanks.


 
Old September 2nd, 2004, 05:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Stella,

Not sure if you have chosen the right place to post this.

Anyways, try this.
Code:
,'" & Format(Wdata, "dd-mm-yyyy") & "')"
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 3rd, 2004, 06:59 AM
Registered User
 
Join Date: Sep 2004
Location: Firenze, , Italy.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Happygv, I tried, but it does'nt run.

I found a method that run:

            Strsql = "Insert into CLI_ENTI SELECT * FROM cli_entibk"
            Tbcli1.Open Strsql, Conn, adOpenKeyset, adLockBatchOptimistic, adCmdText
            Tbcli1.Close

where clienti_bk contain a dummy record with key "0000000". After I update this record and all is ok!!!

Thanks for your interest. Stella2004






Similar Threads
Thread Thread Starter Forum Replies Last Post
visual foxpro programming manoharan BOOK: Beginning XML 3rd Edition 3 November 10th, 2006 04:12 AM
visual foxpro programming sqsean BOOK: Beginning XML 3rd Edition 0 May 3rd, 2006 05:36 AM
Visual foxpro dilipdamodaran BOOK: Beginning XML 3rd Edition 0 April 26th, 2006 04:20 AM
why Visual FoxPro ? badgolfer Other Programming Languages 0 December 8th, 2005 11:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.