none
Open OleDb Connection Exclusively RRS feed

  • Question

  •  

    This is the connection string I am building:

    OleDbConnectionStringBuilder scb = new OleDbConnectionStringBuilder ( );

    scb.Provider = "VFPOLEDB.1";

    scb.DataSource ="C:\\VFP_Projects\\DATA\\ComeAndGetDatBase\\comeAndGet.dbc";

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

    string connString = scb.ToString ( );

     

    For the Add clause ("exclusive" key) I also used 0 & 1 as values instead of "true". They were all compiled and executed (which is my case means that clause "exclusive" appeared to have been ignored).

     

    This connection string is used in two

    using (OleDbConnection conn = new OleDbConnection ( connString ))

    {

      // deletion of records is accomplished here OK.

    }

     

    blocks. The first block deletes some records which in case of VFP DB is tantamount to marking them for deletion. The second block is supposed to execute PACK command. I get an error on ExecuteNonQuery at the second block: "Database must be opened exclusively."

     

    Any hope for help?

     

    Thanks.

    Thursday, October 18, 2007 2:34 PM

All replies

  • Alex,

    I don't think "exclusive" attribute is supported by VFPOLEDB. However there is a mode attribute. Check the documentation.

    And for a simple solution if you promise me to use the code to the letter w/o modifying checkSmile

     

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2289226&SiteID=1

     

    And I repeat here again you don't need to pack.

     

    Thursday, October 18, 2007 10:58 PM
  •  CetinBasoz wrote:

    Alex,

    I don't think "exclusive" attribute is supported by VFPOLEDB. However there is a mode attribute. Check the documentation.

    And for a simple solution if you promise me to use the code to the letter w/o modifying check

     

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2289226&SiteID=1

     

    And I repeat here again you don't need to pack.

     

     

    Thank you Cetin, I feel I are getting closer. I will copy your code and run it now, although I ran parts of it already.

     

    Thanks.

     

    P.S.

     

    Cetin, I just copied your entire DoPack procedure to my C# code, made no changes whatsoever, it compiled but I got the same "Syntax Error" AT RUNTIME which tells me that your string is not correct but I do not understand it at all. I have never seen those VFP commands before. They are not common. I have to read upon them.

    Friday, October 19, 2007 12:57 PM
  •  CetinBasoz wrote:

    Alex,

    I don't think "exclusive" attribute is supported by VFPOLEDB. However there is a mode attribute. Check the documentation.

    And for a simple solution if you promise me to use the code to the letter w/o modifying check

     

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2289226&SiteID=1

     

    And I repeat here again you don't need to pack.

     

     

    OK, I tried your mode attribute:

     

    ConnectionStringBuilder.Add ("mode","out"); since "in" is supposed to be the default. The exception was: Message="Format of the initialization string does not conform to the OLE DB specification."

     

    Mode attribute does not seem to have anything to do with OleDb at all.

    Friday, October 19, 2007 1:26 PM
  • The problem has been effectively bypassed. Thanks.

    Friday, October 19, 2007 3:40 PM