none
Not Enough Memory o Complete the Operation. RRS feed

  • Question

  • 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.

    Thursday, October 18, 2007 6:40 PM

Answers

  • 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);

      }

     }

    }

    Thursday, October 18, 2007 10:24 PM
  • 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.

     

     

     

     

     

    Friday, October 19, 2007 7:34 PM
  • 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.

     

     

     

    Saturday, October 20, 2007 5:23 AM

All replies

  • 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?

    Thursday, October 18, 2007 8:30 PM
  • 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()
    Thursday, October 18, 2007 8:57 PM
  • 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);

      }

     }

    }

    Thursday, October 18, 2007 10:24 PM
  • 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"

    Friday, October 19, 2007 12:54 PM
  • 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.

    Friday, October 19, 2007 2:14 PM
  • 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.

    Friday, October 19, 2007 2:40 PM
  • 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).

    Friday, October 19, 2007 3:33 PM
  • 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?

     

    Friday, October 19, 2007 3:55 PM
  • " 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 ?
    Friday, October 19, 2007 4:37 PM
  •  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.

     

    Friday, October 19, 2007 4:50 PM
  • 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.

     

     

     

     

     

    Friday, October 19, 2007 7:34 PM
  • 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.

     

     

     

    Saturday, October 20, 2007 5:23 AM
  •  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?

    Saturday, October 20, 2007 4:45 PM
  •  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.

    Saturday, October 20, 2007 5:05 PM
  •  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 evan something different, now it does not like the parameter's statement.

     

    Do you have any idea how it can be handled?

     

    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.

    Saturday, October 20, 2007 5:06 PM
  •  

    OK, that's been solved also, I mean passing parameters to VFP via OleDb. A simple, standard approach works flawlessly. 

     

    using (OleDbConnection conn2 = new OleDbConnection ( connString ))

    {

    conn2.Open ( );

    OleDbCommand cmdm2 = new OleDbCommand ( );

    cmdm2.Connection = conn2;

    cmdm2.CommandType = CommandType.StoredProcedure;

    cmdm2.CommandText = "testing";

    cmdm2.Parameters.Add ( "testPar", OleDbType.Integer ).Value = 5;

    OleDbDataReader rdr = cmdm2.ExecuteReader ( CommandBehavior.Default );

    if (rdr.HasRows == true)

    {

    foreach (System.Data.Common.DbDataRecord row in rdr)

    {

    Console.WriteLine (row[ 0 ]);

    }

    }

    } // end of using conn2

     

    I've been waiting nervously for our DNI fellow, a talented possessor of unique skill of typing a keyword into a textbox and collecting a link to an MSDN page that he "genially" bestows onto a lucky poster.

     

    No time to write a sample, though! A man of few words. Just drops a link with no comment whatsoever! Such a helpful hand!

     

    So for the lack of this extraordinary helper aroung I had to do the hard labor of cracking this actually very simple problem. Will never forgive myself. Should have waited.

     

    Well, at least this forum has fun galore. It is a comic relief to rattle some feathered personalities from time to time.

     

    PS. It is so weird, I did not notice the double posting last night, perhaps because the second one overflowed to the next page. Now I cannot delete the duplicate--the delete button is not there. Perhaps the moderator can do it for me.

     

    I am very sorry for that.

     

    Thanks to everyone who tried to help. Special thanks to Cetin.

    Sunday, October 21, 2007 5:26 PM
  • Cetin hi,

     

    I just tested your DoPack procedure with execScript. It worked flawlessly, it seems. At least I did not get any exceptions. I did not have any records marked for deletion in my tables to check but I am sure it will be done.

     

    For a time being I am going to stick with my embeded SP since it has already proven itself worthy but I am planning to keep your code in reserve and I have vague plans to use it perhaps if it offers some advantages. There is a chance that this code may be very convenient for some tasks, specifically for changing/shaping parameters at runtime since your string may be easily manipulated with a StringBuilder.

     

    This code is very helpful.

     

    Thanks again.

    Sunday, October 21, 2007 5:42 PM
  • OK Alex,

    Do it however you want.

    To me it looks like you don't understand StringBuilder's role well. You need SB when you have a string that would be builtSmile

     

    string s1 = "string 1";

    s1 += "string 2";

     

    Do not have a single memory location where result is "string1string2". Instead in the heap this creates two strings "string1" and "string1string2". SB is there to prevent that and is optimized for such operations.

     

    OTOH:

    string myString = @"some very long

    string here written as a single string as is

    including line feeds";

     

    is like VFP's text...endtext if you remember. No need to build such a thing with an SB. It's a single string which is easier to read/write and maintain than SB way of doing the same.

     

    You could simply refactor it:

     

    Code Block

    public void DoDeleteInPath(string path)

    {

        string procedure = String.Format( @"deleteInComeAndGet( '{0}' )

    function deleteInComeAndGet(tcPath)

    *...",

    path);

    // ...

    }

     

     

    And you would not need to change hardcoded path. Instead you'd simply be doing a method call with path parameter. The body of code is static so there is no need for an SB (but nothing prevents you from using an SB).

    Monday, October 22, 2007 10:22 AM
  • <<But Tamar, I understand, is mostly a teacher and book writer. >>

    I'm not sure what gave you that impression but I've been earning money as a software developer since the late 1970's. Yes, I teach and write, but that's the side effort.

    Tamar
    Monday, October 22, 2007 1:04 PM
    Moderator
  •  Tamar E. Granor wrote:
    <<But Tamar, I understand, is mostly a teacher and book writer. >>

    I'm not sure what gave you that impression but I've been earning money as a software developer since the late 1970's. Yes, I teach and write, but that's the side effort.

    Tamar

     

    Oh, Tamar, you do not have to defend your record or reputation--I fell in love with you the moment I saw you standing next to that Rolls Royce with a cigarette in hand on the cover of "What's New in Nine" where you are the lead author. I hope you quit smoking since the picture was takenSmile JK.

     

    Ultimately it is the intellect that matters and I am sure you understand what I mean. This part: No kidding.

    Tuesday, October 23, 2007 4:06 PM
  •  CetinBasoz wrote:

    OK Alex,

    Do it however you want.

    To me it looks like you don't understand StringBuilder's role well. You need SB when you have a string that would be built

     

    Code Block

    public void DoDeleteInPath(string path)

    {

        string procedure = String.Format( @"deleteInComeAndGet( '{0}' )

    function deleteInComeAndGet(tcPath)

    *...",

    path);

    // ...

    }

     

     

     

    Cetin, it is in my nature to leave no stones unturned. I read it first time a week ago and could not understand a thing. What is the purpose of this lecture? I reread it today and still cannot comprehend it. If you think I do not understand the purpose of StringBuilder, think again.

     

    I will show you how I use the StringBuilder class on a different example. It also ends up in an SQL INCLUDE command which is passed to the DB.

     

    The task (expressed in PLAIN English) is:

     

    I have 15 Tables in one of  my VFP DB (comeAndGet). They ALL have some common fields (4 common fields) plus fields which are different from Table to Table because of the nature of the data that is stored in them. The common  fields are:

     

    char: numeric_id, named, date dated & memo memo1.

     

    Table "accounts" has a number of other fields, like accountNumber, routineNumber, etc.

    Table "payments" has fields like: debitNumeric_id, creditNumeric_id, etc.

     

    My goal is to have an INSERT command CLEARLY written, easily understood by the author a year from now and being universal. I do not want to write 15 separate commands.

     

    So I do this:

     

    DateTime dated = DateTime.Now.Date;

    string cDated = dated.ToString ( "MM/dd/yyyy" );

    StringBuilder sbTemp = new StringBuilder ( );

    sbTemp.Append ( "INSERT INTO " + dataTableName + " " );

    if (childsChar == 'C' | childsChar == 'E' | childsChar == 'N' | childsChar == 'Q' | childsChar == 'W')

    {

    // categories, emails, notes, phones, products

    sbTemp.Append ( " (numeric_id, named, dated, memo1) " );

    }

    else

    {

    switch (childsChar)

    {

    case 'H': // accounts

    sbTemp.Append ( " (numeric_id, named, dated, accountType, taxDeductible, " +

    "routing_number, account_id, cur_balance, balanceDate, expirDate, phone, " +

    "email, url, address, currentInterRate, periodic, periodicity, pw, datePwSet, pin, datePinSet, memo1) " );

    break;

    case 'P': // companies

    sbTemp.Append ( " (numeric_id, named, dated, symbolOne, country, exchange, types, " +

    "attrib1, attrib2, scoutRating, memo1) " );

    break;

    case 'X': // diaries

    sbTemp.Append ( " (numeric_id, named, dated, seqNumSameDay, scrambled, memo1) " );

    break;

    case 'F': // files

    sbTemp.Append ( " (numeric_id, named, dated, oper_system, platform, memo1) " );

    break;

    case 'T': // idAndPws

    sbTemp.Append ( " (numeric_id, named, dated, id, pw, memo1) " );

    break;

    case 'G': // payments

    sbTemp.Append ( " (numeric_id, named, dated, debitNumeric_id, creditNumeric_id, " +

    "refNumeric_id, amount, dateReceived, checkNumber, orderumber, debitInstitution, " +

    "creditInstitution, referenceName, modelNumber, firstPmntOfPeriod, lastPmntOfPeriod, memo1) " );

    break;

    case 'S': // persons

    sbTemp.Append ( " (numeric_id, named, dated, first_name, title, memo1) " );

    break;

    case 'U': // urls

    sbTemp.Append ( " (numeric_id, named, dated, clipboard, memo1) " );

    break;

    }

    }

    sbTemp.Append ( " VALUES ( " );

    sbTemp.Append ( " '" + numeric_id + "' " );

    sbTemp.Append ( ", '" + this.txtBoxFindWords.Text.Trim ( ) + "' " ); // text

    sbTemp.Append ( ", CTOD ('" + cDated + "') " );

    string cDated2 = (string)( DateTime.Now.Date ).ToString ( "MM/dd/yyy" );

    switch (childsChar)

    {

    case 'H': // accounts

    string curBalance = "0.0";

    sbTemp.Append ( ", ' ' " ); // accountType

    sbTemp.Append ( ", 'NVL ( " + false + "," + false + " )' " ); // taxDeductible

    sbTemp.Append ( ", ' ' " ); // routing_number

    sbTemp.Append ( ", ' ' " ); // account_id

    sbTemp.Append ( ", 'Val (" + curBalance + ")' " ); // curBalance

    sbTemp.Append ( ", 'CTOD (" + cDated2 + ")' " ); // balanceDate

    sbTemp.Append ( ", 'CTOD (" + cDated2 + ")' " ); // expirDate

    sbTemp.Append ( ", ' ' " ); // phone

    sbTemp.Append ( ", ' ' " ); // email

    sbTemp.Append ( ", ' ' " ); // url

    sbTemp.Append ( ", ' ' " ); // address

    sbTemp.Append ( ", ' ' " ); // currentInterRate

    sbTemp.Append ( ", 'NVL ( " + false + "," + false + " )' " ); // periodic

    sbTemp.Append ( ", ' ' " ); // periodicity

    sbTemp.Append ( ", ' ' " ); // pw

    sbTemp.Append ( ", 'CTOD (" + cDated2 + ")' " ); // datePwSet

    sbTemp.Append ( ", ' ' " ); // pin

    sbTemp.Append ( ", 'CTOD (" + cDated2 + ")' " ); // datePinSet

    break;

    case 'P': // companies

    sbTemp.Append ( ", ' ' " ); // symbolOne

    sbTemp.Append ( ", 'USA' " ); // country

    sbTemp.Append ( ", ' ' " ); // exchange

    sbTemp.Append ( ", ' ' " ); // attrib1

    sbTemp.Append ( ", ' ' " ); // attrib2

    sbTemp.Append ( ", ' ' " ); // scoutRating

    break;

    case 'X': // diaries

    sbTemp.Append ( ", ' ' " ); // seqNumSameDay

    sbTemp.Append ( ", 'NVL ( " + false + "," + false + " )' " ); // scrambled

    break;

    case 'F': // files

    sbTemp.Append ( ", ' ' " ); // oper_system

    sbTemp.Append ( ", ' ' " ); // platform

    break;

    case 'T': // idAndPws

    sbTemp.Append ( " (numeric_id, named, dated, id, pw, memo1) " );

    break;

    case 'G': // payments

    string amount = "1.5";

    sbTemp.Append ( ", ' ' " ); // debitNumeric_id

    sbTemp.Append ( ", ' ' " ); // creditNumeric_id

    sbTemp.Append ( ", ' ' " ); // refNumeric_id

    sbTemp.Append ( ", 'Val (" + amount + ")' " ); // amount

    sbTemp.Append ( ", 'CTOD (" + cDated2 + ")' " );

    sbTemp.Append ( ", ' ' " ); // checkNumber

    sbTemp.Append ( ", ' ' " ); // orderumber

    sbTemp.Append ( ", ' ' " ); // debitInstitution

    sbTemp.Append ( ", ' ' " ); // creditInstitution

    sbTemp.Append ( ", ' ' " ); // referenceName

    sbTemp.Append ( ", ' ' " ); // modelNumber

    sbTemp.Append ( ", 'NVL ( " + false + "," + false + " )' " );// firstPmntOfPeriod

    sbTemp.Append ( ", 'NVL ( " + false + "," + false + " )' " );// lastPmntOfPeriod

    break;

    case 'S': // persons

    sbTemp.Append ( ", ' ' " ); // first name

    sbTemp.Append ( ", ' ' " ); // title

    break;

    case 'U': // urls

    sbTemp.Append ( ", '' " ); // clipboard

    break;

    }

    sbTemp.Append ( ", '' " ); // memo1

    sbTemp.Append ( " ) " ); // closing parenthesis for VALUES

    comndText = sbTemp.ToString ( );

    cmdm.CommandText = comndText;

    cmdm.ExecuteNonQuery ( );

     

    And it works! I mean I haven't checked all options yet because my inability to effect the REPLACE command holds me back.

     

    Some values above are just dummy values (nulls) for debug.

     

    And you have the guts to tell me that I do not understand StringBuilder!

     

    I am sorry, but I simply could not completely understand your English in that post of yours to analyze it soundly. What I posted is the result of my understanding.

     

    You have been helpful to me in the past and I owe you much gratitude but lately I have noticed a lot of irritation in your posts. It seems you either do not understand my questions or my comments focusing on what you think is my lack of basic understanding of elements and lecuring me on that. I do need help with the REPLACE command, period. I do not need all this stuff. So far you haven't offered any clear solution to that. You haven't been able to explain why I am getting Syntax Error. Your explanation that my string is longer than 255 characters is invalid. It is much less than that. I am still waiting for a clear answer.

     

    I am asking you to either analyze what I have tried to do myself and find an error or offer a code sample from your stock. You have been able to do it in the past many times. I hope you can do it again.

     

    Thanks.

    Thursday, October 25, 2007 5:14 PM
  • I am also having this sort of problem but in a different area.

     

    I am making an application, and i am trying to add a .wav file to it,

     

    I have done that, but when i try and attach it to the Resources.resx using the Project Properties,

     

    It says "Not Enough Memory to Complete Operation", or "Not Enough Storage Space"

     

    Can anyone please help me with this

     

    Thank You

     

    Ollie

     

    Thursday, May 15, 2008 3:54 PM
  •  

    I have solved that issue,

     

    Now i am trying to Embed my "sound.wav" file.

     

    but when in sound player i try and play the file, i get:

     

    System.Resources.MissingManifestResourceException was unhandled
      Message="Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure \"Properties.Resources.resources\" was correctly embedded or linked into assembly \"Make a Doc\" at compile time, or that all the satellite assemblies required are loadable and fully signed."
      Source="mscorlib"
      StackTrace:
           at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
           at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
           at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
           at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
           at System.Resources.ResourceManager.GetStream(String name, CultureInfo culture)
           at Properties.Resources.get_sound() in C:\Documents and Settings\Ollie\My Documents\Visual Studio 2005\My Exported Templates\Properties\Resources.Designer.cs:line 65
           at MakeaDoc.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\Ollie\My Documents\Visual Studio 2005\My Exported Templates\Make a Doc.cs:line 130
           at System.Windows.Forms.Form.OnLoad(EventArgs e)
           at System.Windows.Forms.Form.OnCreateControl()
           at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
           at System.Windows.Forms.Control.CreateControl()
           at System.Windows.Forms.Control.WmShowWindow(Message& m)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           at System.Windows.Forms.ContainerControl.WndProc(Message& m)
           at System.Windows.Forms.Form.WmShowWindow(Message& m)
           at System.Windows.Forms.Form.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.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
           at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Control.set_Visible(Boolean value)
           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 MakeaDoc.Program.Main() in C:\Documents and Settings\Ollie\My Documents\Visual Studio 2005\My Exported Templates\Program.cs:line 17
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
           at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

    Can anybody please help me, as i am really stuck now Sad

     

    Thank You

     

    Oliver Christie

    Big Bite Entertainment

    Friday, May 16, 2008 11:13 AM
  • Now i am trying to Embed my "sound.wav" file.

     

    Is winmm.dll referenced?

    Friday, May 16, 2008 3:12 PM