IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

Types variables création table ACCESS [Débutant]


Sujet :

C#

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Octobre 2010
    Messages : 166
    Par défaut Types variables création table ACCESS
    Bonsoir

    Voila une petite question simple pour un dimanche soir :

    est-ce que quelqu'un sait où je pourrais trouver les types de variables pour une base ACCESS ?

    je souhaite faire un "CREATE TABLE ...."

    merci

    bonne soirée

    KaloOopS

  2. #2
    Inactif  
    Profil pro
    Inscrit en
    Novembre 2002
    Messages
    123
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2002
    Messages : 123
    Par défaut oh c'est très simple
    les types de variables sont celles du langage SQL uniquement. si vous souhaitez des précisions n'hésitez pas
    Bonne soirée

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Octobre 2010
    Messages : 166
    Par défaut
    Citation Envoyé par olivieram Voir le message
    si vous souhaitez des précisions n'hésitez pas
    heu ... ben oui ...

  4. #4
    Inactif  
    Profil pro
    Inscrit en
    Novembre 2002
    Messages
    123
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2002
    Messages : 123
    Par défaut SQL types
    alors, de mémoire, les plus courantes :
    int : entier
    real : décimal
    nvarchar(size) : chaîne de caractères unicode
    varchar(size) : chaîne de caractères ANSI
    date ou datetime : date
    money : décimal à 2 chiffres après la virgule

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2007
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 106
    Par défaut
    Il fût un temps où j'ai utilisé des bases ACCESS en C#... J'utilisais les types suivants:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
     
        protected OleDbType GetDbType(MyDbType myDbType)
        {
            switch (myDbType)
            {
                case MyDbType.Int32:
                    return OleDbType.Integer;
                case MyDbType.Boolean:
                    return OleDbType.Boolean;
                case MyDbType.DateTime:
                    return OleDbType.DBTimeStamp;
                case MyDbType.String:
                    return OleDbType.VarChar;
                case MyDbType.StringFixedLength:
                    return OleDbType.Char;
                default:
                    throw new NotSupportedException("GetSpecificDbType " + myDbType.ToString());
            }
        }
        protected override string GetDbTypeString(MyDbType myDbType)
        {
            switch (myDbType)
            {
                case MyDbType.Int32:
                    return "Integer";
                case MyDbType.Boolean:
                    return "bit";
                case MyDbType.DateTime:
                    return "datetime";
                case MyDbType.String:
                    return "VarChar";
                case MyDbType.StringFixedLength:
                    return "Char";
                default:
                    throw new NotSupportedException("GetDbTypeString " + myDbType.ToString() + " Not Supported ");
            }
        }
     
     
     
            public enum MyDbType
            {
                Int32, // SqlServer:int
                Boolean, // SqlServer:bit
                DateTime, // SqlServer:datetime
                String, // SqlServer:ntext/nvarchar/...
                StringFixedLength // SqlServer:char(x)
            }
    C'est pas complet, mais si ça peut t'aider

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Octobre 2010
    Messages : 166
    Par défaut
    merci

    @++

    KaloOopS

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2007
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 106
    Par défaut
    Au fait pour répondre à ta question:
    http://msdn.microsoft.com/en-us/libr...(v=VS.90).aspx

  8. #8
    Membre extrêmement actif
    Inscrit en
    Avril 2008
    Messages
    2 573
    Détails du profil
    Informations personnelles :
    Âge : 65

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 573
    Par défaut librairie com Adox et Microsoft ActiveX Data Object
    bonjour
    tu passes par la lib com ADOX (Microsoft ADO Ext 2.8 For DDL and Security) & ADODB(Microsoft ActiveX Data Object 2.8 Library).
    Le numero de version depend de la version Access intalle sur ta machine.
    Voici un exemple de projet Application WinForm qui cree une bd et lui ajoute une table.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    //panneau com ajouter une reference à:
    // Microsoft ADO Ext 2.8 For DDL and Security
    //(librairie DLL=> Data Definition Language)  
    using ADOX;
    //Microsoft ActiveX Data Object 2.8 Library
    using ADODB;
    using System.IO;
    namespace AdoxCSharp
    {
        public partial class Form1 : Form
        {
        //Declare un  mdb
        private  ADOX.Catalog Cat;
     
        private  string cheminApp= Directory.GetCurrentDirectory() + "\\" ;
        private  string nomBase= "maBase.mdb";
            public Form1()
            {
                InitializeComponent();
            }
     
            private void btnCreateMDB_Click(object sender, EventArgs e)
            {
                Cat  = new ADOX.Catalog();
                Cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
                     "Data Source=" + cheminApp + nomBase + ";" +
                      "Jet OLEDB:Engine Type=5");
     
                Console.WriteLine("Database Created Successfully");
     
                Cat = null;
            }
     
            private void btnCreateTable1_Click(object sender, EventArgs e)
            {
                ADODB.Connection Cn ;        
                ADOX.Table  objTable ;
                ADOX.Key objKey ;
     
            Cn = new ADODB.Connection();
            Cat =new ADOX.Catalog();
            objTable = new ADOX.Table();
     
            //Open the connection
     
            Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cheminApp + nomBase, string.Empty, string.Empty, 0);
     
            //Open the Catalog
            Cat.ActiveConnection = Cn;
     
            //Create the table
            objTable.Name = "Test_Table";
            //Create and Append a new field to the "Test_Table" Columns Collection
     
                objTable.Columns.Append( "PrimaryKey_Field",  ADOX.DataTypeEnum.adInteger,0);
     
            //'Create and Append a new key. Note that we are merely passing
            //'the "PimaryKey_Field" column as the source of the primary key. This
            //'new Key will be Appended to the Keys Collection of "Test_Table"
                objTable.Keys.Append("PrimaryKey", ADOX.KeyTypeEnum.adKeyPrimary, "PrimaryKey_Field", String.Empty, String.Empty);
     
            //'Append the newly created table to the Tables Collection
                Cat.Tables.Append(objTable);
     
            //' clean up objects
            objKey = null;
            objTable =  null;
            Cat = null;
            Cn.Close();
            Cn =  null;
            }
     
         }
    }
    bon code....

  9. #9
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Octobre 2010
    Messages : 166
    Par défaut
    Impeccable !!

    merci pour le lien chez crosoft c'est ce que je n'arrivais pas a trouver

    mais bon c'est sur que "OleDbType Enumeration" c'est pas pareil que "declaration types variables ACCESS"

    merci

    @++

    KaloOopS

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] Création table ACCESS
    Par thomasaurelien dans le forum VB.NET
    Réponses: 0
    Dernier message: 29/11/2011, 17h54
  2. PB de création de table Access via JDBC
    Par jakouz dans le forum JDBC
    Réponses: 1
    Dernier message: 04/12/2007, 17h29
  3. Limites Création table tempo Access par ADOX via Excel VBA.
    Par botakelymg dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 16/11/2007, 09h45
  4. [access-odbc] création table temporaire
    Par maraly dans le forum Access
    Réponses: 4
    Dernier message: 30/05/2007, 09h47
  5. insertion d'un type date dans une table access
    Par monstour dans le forum ASP
    Réponses: 7
    Dernier message: 18/06/2004, 16h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo