Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/05/2009, 14:26
Avatar de gogupe
gogupe
 
Fecha de Ingreso: octubre-2006
Ubicación: Mallorca
Mensajes: 897
Antigüedad: 18 años, 6 meses
Puntos: 32
Respuesta: Como generar un base de datos automaticamente

Hola buxforever

Tienes que hacer lo siguiente, te pongo un ejemplo que lo uso yo y que me funciona muy bien.

Tienes que agregar la referencia: Microsft Ado Ext ...

A continuación

Código:
Dim Cat As ADOX.Catalog

Set Conexion_MDB = New ADODB.Connection
Set Rst_Mdb = New ADODB.Recordset
Set Cat = New ADOX.Catalog


' Crear la base de datos
Cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Dire_Mdb & ";"


Conexion_MDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mi_base_de_datos\bd.mdb"


Conexion_MDB.Open

Rst_Mdb.ActiveConnection = Conexion
Rst_Mdb.CursorLocation = adUseClient
Rst_Mdb.CursorType = adOpenDynamic
Rst_Mdb.LockType = adLockBatchOptimistic

Conexion_MDB.Execute "CREATE TABLE nombre_tabla  " & _
    "(id autoincrement," & _
    "nombre text(255)," & _
    "apellidos text(255)," & _
    "primary key(id))"
    
Conexion_MDB.Close
Set Conexion_MDB = Nothing

Set Rst_Mdb = Nothing
Set Cat = Nothing

End Function
De este modo ya tienes creada la tabla, me imagino que el resto sabrás hacerlo ¿No?

Saludos.