×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Btrieve v6.15 Error 51

Btrieve v6.15 Error 51

Btrieve v6.15 Error 51

(OP)
Hi,

I can successfully open a Btrieve file with the owner set with BUTIL, but when I attempt to open it via code (C#) I get an error 51 "Invalid Owner"!  I have set the owner name in the following Structure, it is 6 chars in length so have set the dataLen to 7 to allow for the binary 0 at the end:

[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi, Size=8)]
    public struct BTR_OWNER_NAME
    {
        public string    OwenerName;
    }

but when I attempt top open the file with:

bStat = BtrCall.BTRCALL( (ushort)BTROPS.B_OPEN, posBlock, ref ownerBuf, ref dataLen, keyBuffer, keyLen, keyNum );

I get the error 51!!!!  Can someone PLEASE assist.

RE: Btrieve v6.15 Error 51

I was this in the documentation:

If this status code occurred during an Open operation or a DROP TABLE statement, the application attempted to open a file that has an owner name assigned to it. The application must specify the correct owner name in the data buffer. Ensure that the owner name is null-terminated in the data buffer and that the data buffer length is set long enough to include the owner name plus the null terminator.

This might not make any difference, but you have the following line:

       public string    OwenerName;

I don't know C all that well but could it be that the variable should be OwnerName and a blank value is being passed instead of the actual owner name.

Hope this helps...

RE: Btrieve v6.15 Error 51

(OP)
Prior to the Open I was assigning the owner name as follows:

ownerBuf.OwenerName = OWNER_NAME;

The OWNER_NAME const has a string as is:

OWNER_NAME = "mypass";

... and I have set the dataLen to 1 more than the number of chars and have even looped through the struct to check that it is terminated with a binary null, and it is.  It is also the correct owner name as I set it with BUTIL and have since cleared it again.

When the owner name is not set and I open with a IntPtr.Zero this works fine, but when I open with a ref to my struct then I get error 51 despite the correct owner name having been set on the struct!!!

RE: Btrieve v6.15 Error 51

(OP)
For the record I have solved it thus:

Create a structure in which to store the Owner Name:

[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi, Size=8)]
    public struct BTR_OWNER_NAME
    {
        public string OwenerName;
    }

//Declare a struct var:

BTR_OWNER_NAME ownerBuf;

//Assign the constant in which the Owner Name is held (this contains 6 chars):

ownerBuf.OwenerName = OWNER_NAME;

//Pass the length of the Owner Name +1 for the trailing Binary 0 into var:

dataLen = 7;

// move our owner structure into unmanaged memory block
                dataBuffer = Marshal.StringToHGlobalAnsi(ownerBuf.OwenerName);

// and finally issue OPEN (0) operation to Btrieve with the dataBuffer containg the Owner Name:

try
                {
                    bStat = BtrCall.BTRCALL( (ushort)BTROPS.B_OPEN, posBlock, dataBuffer, ref dataLen, keyBuffer, keyLen, keyNum );
                }
                catch( Exception e )

bStat has been assigned 0, so all is fine and the Btrieve file which has an Owner Name set with access level 0 is now open.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close