AlexBB


There is a chance that this is not the forum where I will ultimately get an answer since I do not know where the root of the problem is but still I am asking for everyone's attempt to brainstorm.

It is actually a continuation of the previous notorious PACK <tableName> thread. Since I felt that I ran into a stonewall I devised a DEVIOUS (!) plan to crack the problem. It appears to have worked but as always VFP has many nasty surprises in store and this is one of them.

This is my plan.

I set up a BLANK database: blankDb, no tables just one stored procedure in it. This is the text of the stored procedure:

PROCEDURE packTablesInComeAndGet

SET PATH TO "C:\VFP_Projects\Data\ComeAndGetDatBase\"

OPEN DATABASE comeAndGet EXCLUSIVE

USE categories IN 0

SELECT categories

PACK

USE

USE crossRefTable IN 0

SELECT crossRefTable

PACK

USE

ENDPROC

In the .NET C# app I coded this:

OleDbConnectionStringBuilder scb = new OleDbConnectionStringBuilder ( );

scb.Provider = "VFPOLEDB.1";

scb.DataSource = "C:\\VFP_Projects\\DATA\\BlankDb\\blankdb.dbc";

scb.Add ( "exclusive", "true" );

string connString = scb.ToString ( );

using (OleDbConnection conn2 = new OleDbConnection ( connString ))

{

conn2.Open ( );

OleDbCommand cmdm2 = new OleDbCommand ( );

cmdm2.Connection = conn2;

cmdm2.CommandType = CommandType.StoredProcedure;

cmdm2.CommandText = "packTablesInComeAndGet";

try

{

cmdm2.ExecuteNonQuery ( ); // DATABASE Packed

}

catch (Exception ex)

{

Console.WriteLine ( "2nd SB (PACK): \r\n{0}, \r\n{1}", ex.Message, ex.StackTrace );

}

} // end of using conn2

To my surprise the error I got was: "Not Enough Memory to Complete the operation."

I think I am on the way to the final resolution. This scheme opens a foreign" database (ostensibly exclusively, but this statement is in fact ignored--the exclusivity here is not really needed though). It then runs a SP (shown above). It appears the SP did run or attempted to run at least. It did not complain about any exclusivity, since it is almost as running this code from a Command Window. But it ran out of memory!!!

Which memory Why I don't get the same error when I run this code (many, many times) from my CW

Is it something in the buffer between VFP and C# ,NET app

Is there a parameter in VFP which I can try to influence, perhaps adding some lines to this SP

Please please help.





Re: Not Enough Memory o Complete the Operation.

AlexBB


Also I hope Cetin can comment on this idea. Perhaps I could use another Service Provider, e.g.

Microsoft.Jet.OLEDB.4.0

I tried it but got an error

System.Data.OleDb.OleDbException was unhandled
Message="Could not find installable ISAM."
Source="Microsoft JET Database Engine"
ErrorCode=-2147467259

How can I install ISAM for it







Re: Not Enough Memory o Complete the Operation.

AlexBB

I ran it again with complete StackTrace on the exception. Got the error code, googled for it and found out that this error code has nothing to do with any memory at all. It is mostly an ASP.NET issue:

System.Data.OleDb.OleDbException was unhandled
Message="There is not enough memory to complete this operation."
Source="Microsoft OLE DB Provider for Visual FoxPro"
ErrorCode=-2147467259
StackTrace:
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at ComeAndGet.Form1.deleteItem() in C:\VCsharp_Projects\ComeAndGet\ComeAndGet\Form1.cs:line 1911
at ComeAndGet.Form1.pushDelete_Click(Object sender, EventArgs e) in C:\VCsharp_Projects\ComeAndGet\ComeAndGet\Form1.cs:line 1663
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at ComeAndGet.Program.Main() in C:\VCsharp_Projects\ComeAndGet\ComeAndGet\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()






Re: Not Enough Memory o Complete the Operation.

CetinBasoz

One more time giving you the code hoping this time you readSmile

private void DoPack()

{

string procedure = @"

packTablesInComeAndGet(C:\VFP_Projects\Data\ComeAndGetDatBase\')

Procedure packTablesInComeAndGet(tcPath)

Use (Addbs(m.tcPath)+'categories') Exclusive

Pack

Use

Use (Addbs(m.tcPath)+'crossRefTable') Exclusive

Pack

Use

Endproc";

OleDbConnectionStringBuilder scb = new OleDbConnectionStringBuilder();

scb.Provider = "VFPOLEDB";

scb.DataSource = "C:\\Temp";

string connString = scb.ToString();

using (OleDbConnection conn2 = new OleDbConnection(connString))

{

conn2.Open();

OleDbCommand cmdm2 = new OleDbCommand();

cmdm2.Connection = conn2;

cmdm2.CommandType = CommandType.StoredProcedure;

cmdm2.CommandText = "Execscript";

cmdm2.Parameters.Add("p",OleDbType.Char).Value = procedure;

try

{

cmdm2.ExecuteNonQuery(); // DATABASE Packed

Console.WriteLine("Done Alex.");

}

catch (Exception ex)

{

Console.WriteLine("2nd SB (PACK): \r\n{0}, \r\n{1}", ex.Message, ex.StackTrace);

}

}

}





Re: Not Enough Memory o Complete the Operation.

AlexBB

Cetin, thank you very much for working with me.

There are still problems. I got a "Syntax Error" Exception at ExecuteNonQuery at runtime and since I do not understand the syntax of your string procedure I could not do anything to correct.

If you look at the string and notice something wrong I would immediately do another try.

However, there is a problem here. In a way this code, which I appreciate and will definitely explore, may be a diversion.

My OleDb SPs do work. I am now getting in trouble on a different level.

When I try to do PACK in my SP two things happen:

(1) if a table is large, I get "Not Enough Memory To Complete the operation" exception. So, as far as coding in C# is concerned, I am well past this stage. I do not think your code will prevent this exception from happening.

(2) If the Table size is small, however, another thing, very-very Vista related is taking place. I get an exception that an attempt has been made to read or write protected memory. You will see the whole message below but do not believe what it says about memory being corrupt. It is a Vista protected memory. Most likely it is somewhere in Program Files\Visual FoxPro 9\ or elsewhere.

This part is being addressed to you and perhaps to Tamar if she reads it first. I want to know where in the directory the temporary tables for PACK command are stored. If I can pinpoint that I will take care of the rest. However it still be a solution for very small tables only.

So, the bottom line is: please examine your string, I will try it for sure and report. I do not believe, however, it will advance me beyond the point where I am now for the reason I explained above.

System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="System.Data"






Re: Not Enough Memory o Complete the Operation.

AlexBB

OK, I did a small surgery on my SP. I changed the Table I was going to PACK to the name of my SMALLEST Table with perhaps 40 rows. There were NO records marked for deletion in it. Also I removed SELECT statement.

PROCEDURE testing
SET PATH TO "C:\VFP_Projects\Data\ComeAndGetDatBase\"
OPEN DATABASE comeAndGet EXCLUSIVE
USE crossRefFirstLevel IN 0
PACK
USE
CLOSE DATABASES ALL
ENDPROC

The result: The exception related to inability to read/write protected memory disappeared but the "out of memory" exception persists.

This appears to be the FINAL stumbling block to the resolution of the whole ordeal.

Any insight

Still I want to find the place where Temp files (tables) are stored and redirect the stream from it. Perhaps it will help.

Thanks.






Re: Not Enough Memory o Complete the Operation.

AlexBB

Since I am at standstill, I went back to your string, examined it carefully, changed nothing but made it more readable and could not find anything wrong with it. I would have written a similar string:

string procedure = @"packTablesInComeAndGet(C:\VFP_Projects\Data\ComeAndGetDatBase\')

Procedure packTablesInComeAndGet ( tcPath )

Use ( Addbs(m.tcPath)+'categories' ) Exclusive

Pack

Use

Use ( Addbs(m.tcPath)+'crossRefTable' ) Exclusive

Pack

Use

Endproc";

I did another run and got the same "Syntax Error."

I also want to let you know that I am trying numerous minor modifications hoping that will help but to no avail.

I tried to remove "m.", removed last backSlash at the path, added IN 0 to th eUSE statements, etc. Nothing works. The same syntax error. I restored your string to its original shape and I am waiting for your comment.






Re: Not Enough Memory o Complete the Operation.

AlexBB

OK, I cracked the problem completely. Now My SP does a perfect DELETE. All those error messages were misleading which is perhaps characteristic of FoxPro sloppy support. I remember now many such instances in the past.

I will continue to extricate myself from this terrible system that costs you so much wasted time. I noticed a few days ago a post by someone saying: "New to Fox, have many questions."

I have one answer: "STAY AWAY FROM IT."

Anyhow, the solution was:

PROCEDURE packTablesInComeAndGet

SET EXCLUSIVE ON

SET PATH TO "C:\VFP_Projects\Data\ComeAndGetDatBase\"

OPEN DATABASE comeAndGet EXCLUSIVE

USE categories IN 0 EXCLUSIVE

PACK

USE

USE crossRefTable IN 0 EXCLUSIVE

PACK

USE

CLOSE DATABASES ALL

ENDPROC

This is a stored procedure in VFP dummy (blank) database. Instead of complaining that it wanted a strict adherence to EXCLUSIVE clauses at every step it gave me that run around. It is abhorrent.

Cetin, I thank you for your efforts. I really appreciate your help (as always).






Re: Not Enough Memory o Complete the Operation.

AlexBB

OK, I am not out of the woods yet, believe it or not. The Fox really has a tight grip on you once you've touched it unawares of consequences.

The records are deleted all right. However, there appears to be a stituation when I get the same error: "There is not enough memory to complete the operation." This is how it happens.

When I add an item to a treeView (any branch) I store this item's paramaters: numeric_id plus text in a table. Another table gets a record with the parent node.numeric_id plus this child node.numeric_id which are stored as node.Name string.

It turns out I can delete any nodes (and underlying records) if I did not ADD them during this run, If I ADDed them just now, I get that nasty "out of memory" exception which is a total nonsense of course.

I open and close connections for every operation. Before I pack the connection that did the delete is closed. What could be the problem






Re: Not Enough Memory o Complete the Operation.

dni

" I will continue to extricate myself from this terrible system that costs you so much wasted time. I noticed a few days ago a post by someone saying: "New to Fox, have many questions."

I have one answer: "STAY AWAY FROM IT."

Anyhow, the solution was:

PROCEDURE packTablesInComeAndGet

SET EXCLUSIVE ON

SET PATH TO "C:\VFP_Projects\Data\ComeAndGetDatBase\"

OPEN DATABASE comeAndGet EXCLUSIVE

USE categories IN 0 EXCLUSIVE

PACK

USE

USE crossRefTable IN 0 EXCLUSIVE

PACK

USE

CLOSE DATABASES ALL

ENDPROC "

Congratulations for your "genial" Solution. I am totaly amazed ...

And your conclusion is brilliant!!!! Why don't apply it beginning with you




Re: Not Enough Memory o Complete the Operation.

AlexBB

dni wrote:

" I will continue to extricate myself from this terrible system that costs you so much wasted time. I noticed a few days ago a post by someone saying: "New to Fox, have many questions."

I have one answer: "STAY AWAY FROM IT."

Anyhow, the solution was:

PROCEDURE packTablesInComeAndGet

SET EXCLUSIVE ON

SET PATH TO "C:\VFP_Projects\Data\ComeAndGetDatBase\"

OPEN DATABASE comeAndGet EXCLUSIVE

USE categories IN 0 EXCLUSIVE

PACK

USE

USE crossRefTable IN 0 EXCLUSIVE

PACK

USE

CLOSE DATABASES ALL

ENDPROC "

Congratulations for your "genial" Solution. I am totaly amazed ...

And your conclusion is brilliant!!!! Why don't apply it beginning with you

What does your idiotic humor mean That you are amazed that it is so simple I am too. Then explain to me why I was getting all those idioric exceptions which had nothing to do with the subject

Also explain to me, how come you, so experienced and dedicated Foxro enthusiast, could not offer this simple solution

Or perhaps you "saw" the truth all along but enjoyed me frying my mind to solve the problem.

This is the true nature of this forum: selfishness and hostility. Very little help, with the only exception of Cetin who is above all this. I understand that one of the reasons that he is willing to help is his desire to learn the new stuff himself and this is not only perfectly fine but admirable.

The rest of the pros here is just...... I won't continue. I also want to exclude Tamar from this diatribe who has been trying to help me now and in the past. But Tamar, I understand, is mostly a teacher and book writer. I am a code writer. There is a difference.

On the passing note: do you understand the meaniing of the word "genial " If you did you would not have used it here.

PS. I decided to add this as well. You seem to be a new person here, not aware of the rules of the game I established for this forum years ago: If you do not want to help, stay out of my posts, DO NOT TOUCH them at all. Many others have learned this lesson.






Re: Not Enough Memory o Complete the Operation.

CetinBasoz

Alex,

It was a very little typoSmile I forgot to put starting single quote in path. That code however is the one you should stick to, not your solution. Yours is open to errors (mine is either not checking exclusivity but relatively smaller surface).

You shouldn't say "stay away ...". It is nonsense. When I don't understand C++ should I make a call that you should stay away from C VFP is not perfect but you already should have seen that .Net isn't either. For example VS.Net is the only IDE I have ever seen that a designer complains about code generated by itself! Anyway I love both VFP and .Net (and some other languages too).

Your comments about members is one another thing that hurts. Messages may or may not be helpfull to you but at the end they are reserving time to help you. dni and you getting it to a personal level and I beg you both to keep it civil.





Re: Not Enough Memory o Complete the Operation.

Don Higgins

From Alex:

"The rest of the pros here is just...... I won't continue. I also want to exclude Tamar from this diatribe who has been trying to help me now and in the past. But Tamar, I understand, is mostly a teacher and book writer. I am a code writer. There is a difference."

The difference is her code always works, yours.........

Tamar is one of the best, period. She teaches, writes complete applications, writes books, and is as good at VFP as anyone out here.

I can tell you that when she was trying to learn FoxPro many years ago she listened and learned from those before her. She was never hostile to another developer. That is why she is so highly regarded.

If you want to learn VFP you are going about it in the wrong way. Like I said many times, your skill level is not where it needs to be, you need an onsite tutor to help you get over the hump.

What "lessons" have you ever taught another programmer What skills could you possilby have that anybody else could use From where we sit the only thing you teach is how NOT to get your questions answered. You have even insulted Cetin, who was the ONE and ONLY person LEFT who ever offered to help with your questions. You have already alienated the rest of us. Nice going.

This is why nobody helps you. We only help those who help themselves. We will let you flounder.






Re: Not Enough Memory o Complete the Operation.

AlexBB

Don Higgins wrote:

The difference is her code always works, yours.........

Tamar is one of the best, period. She teaches, writes complete applications, writes books, and is as good at VFP as anyone out here.

I can tell you that when she was trying to learn FoxPro many years ago she listened and learned from those before her. She was never hostile to another developer. That is why she is so highly regarded.

If you want to learn VFP you are going about it in the wrong way. Like I said many times,

Her code works, I am sure. Mine works also, I can assure you. The difference between my code and hers, or actually, perhaps, the rest of the handful of guys here who are in this VFP teaching and writing books business is that I doubt some of them have written more than 10,000 lines of code in their lifetime. It is mostly demos for the books and webcasts, etc. I deduced it from some of the comments they were making to me in the past. My experience is 2 orders of magnitude larger. And I am not even a professional programmer. I do not call myself a programmer at all. For a living I do totally different things although I use my programming to support it.

I have never wanted to learn anything about Fox on top of what I need to accomplish my tasks, I am perfectly comfortable being ignorant, and I've said it many times. Apparently you have trouble remembering.

It is unpleasant that you took a position of defending Tamar for a simple reason that I did not say anything bad about her, on the contrary, I praised her. She has tried sincerely help and I appreaicte it.

We've never had a single argument. There was a moment in the past when the then moderator announced a sort of a boycott of my posts and she was the first one who broke it. I appreciated it greatly.

You all have this notorious tendency to force people do things your way. Some people just cannot or do not want to. Can't you understand it






Re: Not Enough Memory o Complete the Operation.

AlexBB

CetinBasoz wrote:

Alex,

It was a very little typo I forgot to put starting single quote in path. That code however is the one you should stick to, not your solution. Yours is open to errors (mine is either not checking exclusivity but relatively smaller surface).

Yep, you didSmile When I looked back at the string, I was kind of shocked myself: many things are visible to your eye but not to your mind.

I will check the proc later today. Mine is working perfectly well also. I do not see any reason to switch. However, there is an issue I would appreciate if you take a look at, it is an issue of passing parameters to the SPs from OleDb.

One of the reasons I want to stick with this SP is the fact that I have a huge library of computational routines written to my current dismay in VFP code. I wrote them while doing that VFP application. They compute special functions and various statistical correlations, they worked well and fast. If I completely master all aspect of calling SPs from OleDb I will be able to reuse them now not rewrite them in C#.

Anyhow, I tried to pass parameters to this routine (my routine, not yours) whose code is posted before in this thread. I did minor modifications in the routine in VFP itself, added LPARAMETERS statement and in C#:

OleDbParameter par = new OleDbParameter ( );

par.ParameterName = "parString";

par.DbType = DbType.String;

par.Value = parString;

cmdm2.Parameters.Add ( par );

cmdm2.ExecuteNonQuery ( );

I got an exception. You can guess what it was: "Cannot read or write protected memory...." garbage. Typical VFP "useful" information. Before the same message signified something else, before that even something different, now the same message means that it does not like the Parameters statement.

Do you have any idea how it should be handled If you do it will save me much time of experimenting, adding a clause here or there and removing them.

I am talking about parameters (in this particular case, just one string) passed to the routine, not the name of the routine.

Thanks. As always I appreciate your insight.

PS. Incidentally, your statement in the other thread that OleDb does not recognize "exclusive=false" statement, although for veracity's sake I should say that you did not state it categorically, just as an opinion, must be a mistake. The reason for that is that I found this statement "exclusive=0" in a OleDbConnectionString in my app.config file in another project and I know I did not put it in there: this file is generated by CLR, I guess, or MIDL. I have no idea what "0" value means, I assumed that it was equal to false, I tried "1" and that was ignored, I tried "2" that was ignored also, then I put in "true" with the same result--nothing happened.

I could not find any enumeration information for "exclusive" anywhere.

Now of course it is all irrelevan but I won't mind to know the truth.