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.
|