0

I am using PHP to enter data in a visual Foxpro 9 database.

My problem is that the ODBC driver is imposing a limit of 255 characters on memo fields.

I tried using the following to get round the problem:

$sSQL = 'Insert Into detail (IT_DOC,IT_MEMO) values (?,?)';

$stmt = odbc_prepare($conn, $sSQL);
$res = odbc_execute($stmt, array($head['IT_DOC'] , $text));

However, this gives me the error:

Warning: odbc_execute() [function.odbc-execute]: SQL error: [Microsoft][ODBC Driver Manager] 
Driver does not support this function, SQL state IM001 in SQLDescribeParameter in C:\inetpub\wwwroot\import.php on line 149

Any help in solving this would be much appreciated.

MasonWinsauer
  • 673
  • 3
  • 14
  • 32
mjsolo
  • 195
  • 2
  • 5
  • 18
  • That limit is there for a reason. It probably uses a single byte to determine the length of the string, and a byte has values of 0 to 255. It's a technical limitation. – C0deH4cker Jun 26 '12 at 16:11

3 Answers3

1

The last time I worked with FoxPro was some time ago, so this might not be correct; but I think when we had this problem, we got around it by writing an empty string in the INSERT or UPDATE statement.

Then, split your string into chucks of 250 characters or less, and UPDATE your memo field by appending them, one after another, to recreate the original string.

It's a horrible, horrible way to do things, though.

andrewsi
  • 10,807
  • 132
  • 35
  • 51
  • Thanks I'll give that a try - not pretty but it might do the trick – mjsolo Jun 26 '12 at 16:16
  • You have my sympathy for having to work with FoxPro; my memories of it aren't very pleasant. – andrewsi Jun 26 '12 at 16:17
  • What you feel is a mild dislike. Give it another couple of years, and you'll hate it. – andrewsi Jun 26 '12 at 16:35
  • Or alternatively, if you gave it a couple of years and learned how powerful it can be when used properly, you might grow to appreciate it. But I wouldn't unless you have to, as the world has moved on somewhat. – Alan B Jun 27 '12 at 10:07
1

Oohhh... those who hate FoxPro... However, I've made a VERY DESCENT living with it since 1987, still use it today in addition to other development languages and still working SQL. Back in the day, it was one of the greatest / fastest databases that didn't require high-priced DBAs, and completely self-contained database and GUI.

I wouldn't use the ODBC driver, but get the latest OleDB driver from Microsoft... you might have better luck...

DRapp
  • 47,638
  • 12
  • 72
  • 142
  • i did try downloading that - couldnt work out how to call it from my php script :( – mjsolo Jun 27 '12 at 09:49
  • @DRapp People have always hated it - yet it refuses to die. And the reason is that during its heyday nothing could touch it. – Alan B Jun 27 '12 at 09:58
  • @AlanB, we can agree to disagree, and it used to be one of the biggest languages to run with... It had object orientation before VB, worked with XML first, and its querying engine is/was excellent. Your generic term of "people have always hated it" is about as politically correct that everything is about ???? whatever you want to fill-in the blanks with. You cant justifiably make a generic statement like that and not have anything to back it up. – DRapp Jun 27 '12 at 12:02
  • Hey, I was standing up for VFP. What I meant was that despite never really fitting in at Microsoft it was and remains extremely popular. As for being object-oriented, not only was it that before VB6, VB6 was *never* object-oriented. – Alan B Jun 27 '12 at 15:55
0

You need to use the OLE DB driver.

This might help: can't connect via OleDB to foxpro *.dbc when in network folder

Alan B
  • 4,086
  • 24
  • 33
  • I tried this and get the following error message: Provider cannot be found. It may not be properly installed.' – mjsolo Jun 28 '12 at 09:44
  • my code is: $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); $conn->Open("Provider=vfpoledb.1;Data Source=C:\Opera3\Comp_I.DBC;Collating Sequence=machine"); – mjsolo Jun 28 '12 at 09:45
  • this is now working using the oledb version :) thanks for the help – mjsolo Jul 02 '12 at 10:07