?
Solved

How to create an Mdb in code

Posted on 1999-12-22
3
Medium Priority
?
158 Views
Last Modified: 2010-04-06
I have moved from D3.02 to D5 (pro)
have a routine written in d3 which works. It's in a unit by its self.  In D5 it crashes and I get the message CoInitialize not Called.  What goes?

Note: I am not using any of the "Servers" from the server page, and also employ late binding.

Here's thre code:

unit Mdb;

interface
uses
  Windows,ComObj, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

 procedure BldMdb(FileName:String);
implementation
 const
  dbLangGeneral = ';LANGID=0x0409;CP=1252;COUNTRY=0';
  dbVersion30 = 32; {choose this for Access 95 database}
  dbEncrypt = 2;
var
  DBEngine: Variant;
  Workspace: Variant;

 procedure BldMdb(FileName:String);

begin
  DBEngine := CreateOleObject('DAO.DBEngine.35');
  Workspace := DBEngine.Workspaces[0];
  Try
  Workspace.CreateDatabase(Filename, dbLangGeneral, dbEncrypt);
  Except
  end;
end;

end.

Thanks,
 Paul Sutton
 
0
Comment
Question by:psutton
3 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 800 total points
ID: 2302372
make sure Application.Initialize is in the dpr file (just before application.run).
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2302473
..or...

Call CoInitialise(Nil) in your initialisation section.

Cheers,

Raymond.
0
 

Author Comment

by:psutton
ID: 2302551
DuuuuuuuuuuuH !! I',m an idiot
Thanks. Appreciate it.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

593 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