Solved

How can I access msysobjects from a VC app

Posted on 1998-05-16
5
274 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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. …
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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

719 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