Link to home
Start Free TrialLog in
Avatar of Liteswitch
Liteswitch

asked on

Question about data types and inserting them into FoxPro tables using VB.Net

Hi all,

I'm currently trying to use the INSERT statement to create new rows in FoxPro 6 tables.  I've managed to do it ok with text strings and integers, but how do I do it for data, boolean and memo fields?

Date type

ie, there is a field, called cseexps, which I suspect is a date field in the foxPro table.  How do I get a text string which is a date as entered into a text box, and both are in the dd/mm/yyyy format, into the date field?  I tried surrounding the variable with ' and also tried # and neither work.

Boolean

In the FoxPro table, some fields are listed as tick boxes, which I assume relates to a true or false declaration.  If I have a text box in which a person enters the word true or false, how do I convert this into the field?

Memo fields

There is a memo field, called csenote, in the FoxPro table.  I've tried inserting text into the field wrapping it ' characters as text, but it doesn't work..  Any idea where I may be going wrong?

I know this is theoretically 3 questions, but they all relate to one problem I am having.  I've put all available points into this question, and I'm quite desperate to get this fixed, as it's confusing me to bits!

thanks,

Liteswitch
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

If I can remember correctly, the date delimiter in FoxPro are the braces {}.

Bob
Avatar of Liteswitch
Liteswitch

ASKER

I tried it with {12/10/2004} and {'12/10/2004'} and no luck.  Although with the first one, I didn't get any errors, it just didn't get entered into the table, which perhaps suggests it's getting there?
What sort of connection are you using?  (oledb?  ODBC?)
I'm using ODBC to connect to the FoxPro DBC file, as I couldn't get OleDb to work properly with it, as the tables were written in FoxPro 6...
Try this format:
{^yyyy/mm/dd}

You should be able to use the Visual FoxPro 8 OleDb driver to access FoxPro 6 tables:

Microsoft OLE DB Provider for Visual FoxPro 8.0:
http://www.microsoft.com/downloads/details.aspx?FamilyID=0f43eb58-7a94-4ae1-a59e-965869cb3bc9&DisplayLang=en

I used this to access FoxPro 2.6a tables.

Bob
Thanks for the help so far, I've managed to sort out the date and time formats using the CDate formatting, and having to change the orderof the dates to get them to work.

Bob, I've managed to get OleDb to work with these particular FoxPro tables before, but using them I can never edit the tables, only view them, which is odd, so I stuck with ODBC as I knew it worked..

Anyway, now I am left with working out the formatting for boolean fields within FoxPro, wherein the fields they are represented by tick boxes, and the formatting for memo fields as well.

That's a good question about boolean, since the values are .T. and .F., but I don't know of the direct equivalence.  It might be integer values, but I have lost a little on this side of the fence since I quit dealing with FoxPro.

Memo fields should just be straight string values with text delimiters.

Bob
I'll have a play around with the Boolean tips, but I'm still having problems with memo fields..

I can put a string into a memo field as text delimiters, but as soon as taht text has any line breaks in it, my code falls over.  So I either need a to find a way to replace the line breaks with a character, insert the memo field tex, then re-replace the characters back with a line break, or find a way of handling line breaks in the code so that it inserts fine into the memo field without any errors.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for that Bob, but I would really prefer not to have to start doing replace functions within this memo field..  Is there no other way of being able to drop the string in without any manilpulation?  Although I suspect not, which is a pain though, oh well.
AFAIK, there isn't any other way.

Bob