Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2005-04-26
14
Medium Priority
?
1,884 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:Liteswitch
  • 5
  • 5
11 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13870013
If I can remember correctly, the date delimiter in FoxPro are the braces {}.

Bob
0
 

Author Comment

by:Liteswitch
ID: 13870227
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?
0
 
LVL 9

Expert Comment

by:Lacutah
ID: 13870705
What sort of connection are you using?  (oledb?  ODBC?)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Liteswitch
ID: 13870766
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...
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13875513
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
0
 

Author Comment

by:Liteswitch
ID: 13885674
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.

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13885713
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
0
 

Author Comment

by:Liteswitch
ID: 13933774
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.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1140 total points
ID: 13934961
If you are going to replace line breaks, then I would suggest using Chr(127), since it is a special character that can never occur naturally within strings (even Unicode doesn't use it).

Replace(memoField, vbCrLf, Chr(127))

Bob
0
 

Author Comment

by:Liteswitch
ID: 13935849
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13936010
AFAIK, there isn't any other way.

Bob
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

571 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