?
Solved

How can I access msysobjects from a VC app

Posted on 1998-05-16
5
Medium Priority
?
275 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 400 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

777 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