Solved

How can I access msysobjects from a VC app

Posted on 1998-05-16
5
267 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
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
tma050898 earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Can you expound on how to copy the file from a "template file"???
0
 
LVL 3

Expert Comment

by:tma050898
Comment Utility
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
Comment Utility
I didn't go with your idea on using the resource file, but the other information was what I needed. Thanks.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now