modify dbf file - ASP

Posted on 2005-05-04
Last Modified: 2012-06-27
I am trying to add a row in a DBF file - Here is my code:

Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "CONVLOG"

if request("submit") = "Post Message" and request("filenm") <> "" then

objconn.execute "INSERT INTO CONVLOG (FILENM,CONVDATE,CONVTIME,USERID,CONVDESC) VALUES ('" & request("filenm") & "','" & Date & "','" & FormatDateTime(Time,4) & "','" &  session("name") & "','" & request("msg") & "')"  

end if

I get this error

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Visual FoxPro Driver]Data type mismatch.
/login/convlog.asp, line 10

Line 10 is the "objconn.execute" line.
I'm not sure what the data type mismatch is - I do know that the field CONVDESC is a memo field and I think the CONVDATE and CONVTIME fields are date/time fields. I'm not even sure how to find out - I didn't create this database; it's a program's database. I can open it in Excel and look around, but I'm pretty much stuck.
Question by:vitanza
    LVL 10

    Expert Comment

    objconn.execute "INSERT INTO CONVLOG (FILENM,CONVDATE,CONVTIME,USERID,CONVDESC) VALUES ('" & request("filenm") & "',#" & Date & "#,#" & FormatDateTime(Time,4) & "#,'" &  session("name") & "','" & request("msg") & "')"  

    assuming USERID is not a number since you have session("name")  going into it.
    if USERID is a number then you do not need the ' 's around it  
    LVL 10

    Expert Comment

    but just to let you know ... #Date# is Access format, so there is a good chance that may not work

    Author Comment

    now I get "Syntax Error"...

    objconn.execute "INSERT INTO CONVLOG (FILENM,CONVDATE,CONVTIME,USERID,CONVDESC) VALUES (" & request("filenm") & ",#" & date & "#,#" & FormatDateTime(time,4) & "#,'" &  session("name") & "','" & request("msg") & "')"  

    I also got rid of the ' 's around filenm because its a number. Well I'm not even sure about that because it's fixed width....example: 00000532. Hmm how can I check the data types of these fields?
    LVL 15

    Accepted Solution

    You could also try deliminating dates and times with { } ...

    Author Comment

    Nice, the { } works. Thanks.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    This video discusses moving either the default database or any database to a new volume.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now