Board index » delphi » Win2K D5 ADO and Access97 HELP!

Win2K D5 ADO and Access97 HELP!

I am trying to create Access97 databases using Win2K, D5 Enterprise, and
ADO.

I use the following code from this newsgroup...When I try to open the
database, I get
the "Unrecognized...." Error.

Any thoughts?

Bill

procedure TSDIAppForm.CreateBlankDatabase;
var
 Catalog  : _Catalog;
 Table    : _Table;
 BaseName : String;
 DS       : String;
begin
// Name of the new database file
  SaveDialog.Execute;
  BaseName := SaveDialog.Filename;
// Create a Catalog Object
  Catalog := CreateCOMObject(StringToGUID('ADOX.Catalog')) as _Catalog;
// Set the Connection String
  DS := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+BaseName;
// Check if we already have such a file and delete it
  If FileExists(BaseName) Then DeleteFile(BaseName);
// Create new Access database
  Catalog.Create(DS);
// Create a Table Object
  Table := CreateCOMObject(StringToGUID('ADOX.Table')) as _Table;
// Set the name of a table
  Table.Name := 'Customers';
// Append Table into the base
  Catalog.Tables.Append(Table);
// Now add two columns (fields) into the table
// Both are Text fields up to 128 characters
 // Table.Columns.Append('FIRSTNAME', adVarWChar, 128);
end;

 

Re:Win2K D5 ADO and Access97 HELP!


Are you when building the conection using the Jet 4.
this realy is a point and click configuration.

walter

Quote
Bill Johnson <b...@aldensys.com> wrote in message

news:89f6e4$ibg9@bornews.borland.com...
Quote
> I am trying to create Access97 databases using Win2K, D5 Enterprise, and
> ADO.

> I use the following code from this newsgroup...When I try to open the
> database, I get
> the "Unrecognized...." Error.

> Any thoughts?

> Bill

> procedure TSDIAppForm.CreateBlankDatabase;
> var
>  Catalog  : _Catalog;
>  Table    : _Table;
>  BaseName : String;
>  DS       : String;
> begin
> // Name of the new database file
>   SaveDialog.Execute;
>   BaseName := SaveDialog.Filename;
> // Create a Catalog Object
>   Catalog := CreateCOMObject(StringToGUID('ADOX.Catalog')) as _Catalog;
> // Set the Connection String
>   DS := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+BaseName;
> // Check if we already have such a file and delete it
>   If FileExists(BaseName) Then DeleteFile(BaseName);
> // Create new Access database
>   Catalog.Create(DS);
> // Create a Table Object
>   Table := CreateCOMObject(StringToGUID('ADOX.Table')) as _Table;
> // Set the name of a table
>   Table.Name := 'Customers';
> // Append Table into the base
>   Catalog.Tables.Append(Table);
> // Now add two columns (fields) into the table
> // Both are Text fields up to 128 characters
>  // Table.Columns.Append('FIRSTNAME', adVarWChar, 128);
> end;

Re:Win2K D5 ADO and Access97 HELP!


Quote
>I am trying to create Access97 databases using Win2K, D5 Enterprise, and
>ADO.

>I use the following code from this newsgroup...When I try to open the
>database, I get
>the "Unrecognized...." Error.

Did you import the ADOX type library?  You need it for that code.
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Win2K D5 ADO and Access97 HELP!


When you say you get an error when opening the database, do you mean opening
it in MS Access 97?  ADO 2.1 creates an Access 2000 database by default.  If
you want to create an Access 97 database, you need to add the jet engine
type to your connection string:

Jet OLEDB:Engine Type=4

Specifying '4' in this parameter creates an Access 97 database.

--
================================================
Ray Porter
Applications Analyst Programmer
Administrative Information Services, UNC-CH
Phone: 966-5878
email: ray_por...@unc.edu
       dra...@email.unc.edu
Home Page: http://www.unc.edu/~dragon/

"Meddle not in the affairs of dragons,
for thou art crunchy and taste good with ketchup."

Quote
"Bill Johnson" <b...@aldensys.com> wrote in message

news:89f6e4$ibg9@bornews.borland.com...
Quote
> I am trying to create Access97 databases using Win2K, D5 Enterprise, and
> ADO.

> I use the following code from this newsgroup...When I try to open the
> database, I get
> the "Unrecognized...." Error.

> Any thoughts?

> Bill

> procedure TSDIAppForm.CreateBlankDatabase;
> var
>  Catalog  : _Catalog;
>  Table    : _Table;
>  BaseName : String;
>  DS       : String;
> begin
> // Name of the new database file
>   SaveDialog.Execute;
>   BaseName := SaveDialog.Filename;
> // Create a Catalog Object
>   Catalog := CreateCOMObject(StringToGUID('ADOX.Catalog')) as _Catalog;
> // Set the Connection String
>   DS := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+BaseName;
> // Check if we already have such a file and delete it
>   If FileExists(BaseName) Then DeleteFile(BaseName);
> // Create new Access database
>   Catalog.Create(DS);
> // Create a Table Object
>   Table := CreateCOMObject(StringToGUID('ADOX.Table')) as _Table;
> // Set the name of a table
>   Table.Name := 'Customers';
> // Append Table into the base
>   Catalog.Tables.Append(Table);
> // Now add two columns (fields) into the table
> // Both are Text fields up to 128 characters
>  // Table.Columns.Append('FIRSTNAME', adVarWChar, 128);
> end;

Other Threads