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
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
les types de variables sont celles du langage SQL uniquement. si vous souhaitez des précisions n'hésitez pas
Bonne soirée
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
Il fût un temps où j'ai utilisé des bases ACCESS en C#... J'utilisais les types suivants:
C'est pas complet, mais si ça peut t'aider
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) }![]()
Au fait pour répondre à ta question:
http://msdn.microsoft.com/en-us/libr...(v=VS.90).aspx
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.
bon code....
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; } } }
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
Partager