Solved

How can I access msysobjects from a VC app

Posted on 1998-05-16
5
273 Views
Last Modified: 2013-11-20
I need to list the objects contained in an ms access db from my VC app. I've tried just about everything but can't seem to get it to work. I get security errors when I try to "select * from msysobjects" using either odbc or dao. However, I can access this table from inside ms access. Is there no way to use this table outside of access???
0
Comment
Question by:RGreene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
tma050898 earned 100 total points
ID: 1311623
You are getting the errors because even Admin doesn't have read priveleges to the catalog tables. Is there any way you can set the priveleges for the database. IOW, if your app is accessing the db, I assume that it is db under your control. When does the db get created and how.

If you are creating the db, maybe you can give Admin read priveleges from within Access. If your program is creating the db, maybe you can copy the new db from a "template db" that has the Admin account set up with read privileges on this table.

HTH,
Tom
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1311624
RGreene,

Did the answer above help you or do I need to provide some additional information?

If the answer above did solve your problem, could you please close it by accepting the answer and grading my help? That way, other programmers having the same problem will have the benefit of this question having been asked and answered.

Thanks,
Tom
0
 

Author Comment

by:RGreene
ID: 1311625
Can you expound on how to copy the file from a "template file"???
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1311626
RGreene,

For example, in our application what we did was the following...

1. Create an empty MS Access db

2. Change the permissions so that admin has read priveleges to the msysobjects table

3. Create a user-defined resource using the Access db...

4. At runtime, when you create your db you can then use code similar to the following in order to load the access db resource and create an access db on disk...
HRSRC hRsrc;
if (NULL != (hRsrc = ::FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(YOUR_RESOURCE_ID), RT_RCDATA)))
{
 HGLOBAL hResource = ::LoadResource(AfxGetInstanceHandle(), hRsrc);

 LPVOID pVoid = ::LockResource(hResource);
 DWORD dwResourceSize = ::SizeofResource(AfxGetInstanceHandle(), hRsrc);  

 CFile fileReportsDatabaseTemplate;
 CFileException e;

 if (fileReportsDatabaseTemplate.Open(_T("YOUR DATABASE NAME"), CFile::modeCreate | CFile::modeWrite, &e ))
 {  
  // file was created
  fileReportsDatabaseTemplate.Write(pVoid, dwResourceSize);
  fileReportsDatabaseTemplate.Close();    
 }
}

5. At this point, the database file will exist and you can access it via within your application. You can also now run your queries against the msysobjects table.

BTW, I prefer keeping the template file as an embedded resource for the simple reason that I didn't want to take a chance on the end-user accidentally deleting this file. This way, I never have to worry about that, nor do I have to worry about versioning issues when I ship out another version of our product.

Tom

0
 

Author Comment

by:RGreene
ID: 1311627
I didn't go with your idea on using the resource file, but the other information was what I needed. Thanks.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 96
centeredAverage challenge 8 186
Annoying "thing" blocks my view 4 134
Problem to App source 6 94
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question