Ver Mensaje Individual
  #1  
Antiguo 12-07-2010
Avatar de yapt
yapt yapt is offline
Miembro
 
Registrado: sep 2006
Ubicación: España
Posts: 258
Reputación: 20
yapt Va por buen camino
Crear base de datos MDB+Jet4 (sin access instalado)

Hola a todos,

después de unas explicaciones del incombustible Neftali, me han convencido de que NO es necesario tener Microsoft Access instalado en un sistema Windows para poder crear, modificar y gestionar una base de datos MDB (que no es lo mismo que Microsoft Access, su gestor).

Me comprometí a investigarlo (incredulo que es uno, pero sin mala fe). Y adjunto el resultado por si a alguien le interesa el asunto o para referencia futura.

Formulario por aquí:
Código Delphi [-]
object Form1: TForm1
  Left = 374
  Top = 204
  Caption = 'Form1'
  ClientHeight = 141
  ClientWidth = 319
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 24
    Top = 16
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object SaveDialog1: TSaveDialog
    Left = 160
    Top = 16
  end
end

Código por allá:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, comobj;

type
  TForm1 = class(TForm)
    Button1: TButton;
    SaveDialog1: TSaveDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Jet4DB: OleVariant;
begin
  if SaveDialog1.Execute then
  try
    Jet4DB := CreateOleObject('ADOX.Catalog');
    Jet4DB.Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+Savedialog1.FileName+';');
    Jet4DB := null;
  except
    on E: Exception do
      ShowMessage(e.message);
  end;

end;

end.

Recogido, casi en su totalidad, de Delphi3000.com:
http://www.delphi3000.com/article.asp?ID=3536

Saludos.
Responder Con Cita