begin process at 2010 02 10 05:44:49
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Base de Donnees

 > EXEMPLE DE CREATION D'UNE BASE DE DONNEES

EXEMPLE DE CREATION D'UNE BASE DE DONNEES


 Information sur la source

Note :
7 / 10 - par 6 personnes
7,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Base de Donnees Niveau :Débutant Date de création :01/11/2004 Date de mise à jour :01/12/2004 01:22:35 Vu / téléchargé :8 699 / 1 356

Auteur : ghitaik

Ecrire un message privé
Commentaire sur cette source (7)
Ajouter un commentaire et/ou une note

 Description

Il faut juste changer les parametres en fonction de l'application et ca va marcher, et il y a toutes les procedures necessaires pour creer une base de donnees

Source

  • Dim db As Database
  • Sub test(NBD As String)
  • If (Dir(NBD) = "") Then
  • Set db = CreateDatabase(NBD, dbLangGeneral)
  • If Not db Is Nothing Then
  • creer_tables db
  • Else
  • MsgBox "erreur"
  • End If
  • End If
  • End Sub
  • Sub champs(tb As TableDef, nom As String, t As Integer, Optional s As Integer, Optional z As Boolean = True, Optional r As Boolean = False)
  • Dim f As Field
  • Set f = New Field
  • f.Name = nom
  • f.Type = t
  • If (s <> 0) Then f.Size = s
  • tb.Fields.Append f
  • f.AllowZeroLength = z
  • tb.Fields(nom).Required = r
  • End Sub
  • Sub indexer(tb As TableDef, nom As String, ref As String, Optional t As Boolean)
  • Dim ind As Index
  • Set ind = New Index
  • ind.Name = nom
  • ind.Fields = ref
  • ind.Primary = True
  • ind.Unique = t
  • tb.Indexes.Append ind
  • End Sub
  • Sub creer_produit(db As Database, nom As String)
  • Dim tb As New TableDef
  • tb.Name = nom
  • champs tb, "ref", dbText, 10, True, False
  • champs tb, "desig", dbText, 10
  • champs tb, "qs", dbInteger
  • champs tb, "pu", dbInteger
  • indexer tb, "xcode", "ref"
  • db.TableDefs.Append tb
  • End Sub
  • Sub creer_client(db As Database, nom As String)
  • Dim tb As New TableDef
  • tb.Name = nom
  • champs tb, "CIN", dbText, 10
  • champs tb, "nom", dbText, 20
  • champs tb, "prenom", dbText, 20
  • champs tb, "adresse", dbText, 30
  • champs tb, "tele", dbInteger, 11
  • champs tb, "fax", dbInteger, 20
  • indexer tb, "xcode", "CIN"
  • db.TableDefs.Append tb
  • End Sub
  • Sub creer_facture(db As Database, nom As String)
  • Dim tb As New TableDef
  • tb.Name = nom
  • champs tb, "Nfact", dbText, 10
  • champs tb, "CIN", dbText, 10
  • champs tb, "date", dbDate
  • indexer tb, "xcode", "Nfact"
  • db.TableDefs.Append tb
  • End Sub
  • Sub creer_articles(db As Database, nom As String)
  • Dim tb As New TableDef
  • tb.Name = nom
  • champs tb, "Nfact", dbText, 10
  • champs tb, "ref", dbText, 10
  • champs tb, "q", dbInteger
  • indexer tb, "xcode", "Nfact"
  • db.TableDefs.Append tb
  • End Sub
  • Sub creer_tables(db As Database)
  • creer_produit db, "produit"
  • creer_client db, "client"
  • creer_facture db, "facture"
  • creer_articles db, "articles"
  • End Sub
Dim db As Database
Sub test(NBD As String)
    If (Dir(NBD) = "") Then
        Set db = CreateDatabase(NBD, dbLangGeneral)
        If Not db Is Nothing Then
            creer_tables db
            Else
            MsgBox "erreur"
        End If
    End If
End Sub
Sub champs(tb As TableDef, nom As String, t As Integer, Optional s As Integer, Optional z As Boolean = True, Optional r As Boolean = False)
Dim f As Field
Set f = New Field
    f.Name = nom
    f.Type = t
    If (s <> 0) Then f.Size = s
    tb.Fields.Append f
    f.AllowZeroLength = z
    tb.Fields(nom).Required = r
End Sub
Sub indexer(tb As TableDef, nom As String, ref As String, Optional t As Boolean)
Dim ind As Index
Set ind = New Index
    ind.Name = nom
    ind.Fields = ref
    ind.Primary = True
    ind.Unique = t
    tb.Indexes.Append ind
End Sub

Sub creer_produit(db As Database, nom As String)
Dim tb As New TableDef
    tb.Name = nom
    champs tb, "ref", dbText, 10, True, False
    champs tb, "desig", dbText, 10
    champs tb, "qs", dbInteger
    champs tb, "pu", dbInteger
    indexer tb, "xcode", "ref"
    db.TableDefs.Append tb
End Sub
Sub creer_client(db As Database, nom As String)
Dim tb As New TableDef
    tb.Name = nom
    champs tb, "CIN", dbText, 10
    champs tb, "nom", dbText, 20
    champs tb, "prenom", dbText, 20
    champs tb, "adresse", dbText, 30
    champs tb, "tele", dbInteger, 11
    champs tb, "fax", dbInteger, 20
    indexer tb, "xcode", "CIN"
    db.TableDefs.Append tb
End Sub
Sub creer_facture(db As Database, nom As String)
Dim tb As New TableDef
    tb.Name = nom
    champs tb, "Nfact", dbText, 10
    champs tb, "CIN", dbText, 10
    champs tb, "date", dbDate
    indexer tb, "xcode", "Nfact"
    db.TableDefs.Append tb
End Sub
Sub creer_articles(db As Database, nom As String)
Dim tb As New TableDef
    tb.Name = nom
    champs tb, "Nfact", dbText, 10
    champs tb, "ref", dbText, 10
    champs tb, "q", dbInteger
    indexer tb, "xcode", "Nfact"
    db.TableDefs.Append tb
End Sub
Sub creer_tables(db As Database)
    creer_produit db, "produit"
    creer_client db, "client"
    creer_facture db, "facture"
    creer_articles db, "articles"
End Sub





 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

01 décembre 2004 01:22:36 :
j'ai enfin ajoute le zip, desolee pour le retard ;)

 Sources de la même categorie

Source avec Zip Source .NET (Dotnet) DATA ACCESS COMPONENT par zaimfaycal
Source avec Zip GESTION ENSEIGNANTS par Elmarzougui
Source avec Zip GESTION D'UNE BIBLIOTHÈQUE par Elmarzougui
Source avec Zip VISUALISATION BASE ACCESS par claude440
Source avec Zip SUPER MONEY par MdelM

Commentaires et avis

Commentaire de Dark_Shadow le 01/11/2004 19:05:09

bien mais un ptit .zip c'est quand même chouette... :)

Commentaire de bluedird le 12/11/2004 14:40:29

j'aurai besoin d'aide pour utiliser cette source...
peut on m'expliquer comme faire?


merci

tomtom

Commentaire de odan71 le 04/03/2005 11:10:57

cooooooooooooool

Commentaire de ghitaik le 05/03/2005 01:59:42

merci, mais si tu as besoin d'un soutien, tu sais je suis la :D

Commentaire de fadelovesky le 07/08/2005 13:51:52

vous m'avez sauver !!! merciiiiiiiiiiiiiiiiiiiiiii!!!

Commentaire de ghitaik le 16/08/2005 14:47:34

pas de quoi, c'est gratuit ;)
ca fait plaisir de savoir que ca aide quelqu'un

Commentaire de titi007 le 19/08/2006 18:23:17

Exelent , il y a de quoi prendre du poil
un similaire pour de l'ADO m'interesse

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,499 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales