Imports
System.Data
Imports
system.Data.OleDb
Imports
dao
Imports
dao.LanguageConstants
Public
Class
Form1
'Déclarer la connexion
Private
Cnx
As
OleDbConnection
' Déclaration l'Objet Commande
Private
Cmd
As
OleDbCommand
'Paramètres de connexion
Private
CnxStr
As
String
Public
Sub
CreateBDD()
Try
'Dim result As Boolean = False
Dim
dbe
As
New
DBEngine
Dim
db
As
Database
db = dbe.CreateDatabase(Application.StartupPath &
"\Calendrier.mdb"
, dbLangGeneral)
If
Not
(db
Is
Nothing
)
Then
db.Close()
Catch
ex
As
Exception
MsgBox(
"Erreur de création de la base de donnée"
& vbCrLf & ex.Message, ,
"Erreur"
)
End
Try
End
Sub
Public
Sub
CreateTable()CnxStr
"Provider Microsoft.Jet.OLEDB.4.0 ; Data Source = "
& Application.StartupPath &
"\Calendrier.mdb;"
Cnx =
New
OleDbConnection
'Donner à la propriété ConnectionString les paramètres de connexion
Cnx.ConnectionString = CnxStr
'Ouvrir la connexion
Cnx.Open()
'Instancier un objet Commande
Cmd =
New
OleDbCommand
'Lier Commande et Connexion
Cmd.Connection = Cnx
'Indiquer le type de commande
Cmd.CommandType = CommandType.Text
'Create Table Commande
Cmd.CommandText =
"CREATE TABLE "
& tssl2.Text &
" (ID AUTOIncrement NOT NULL PRIMARY KEY, HEURES VARCHAR(10) NOT NULL, DESCRIPTION MEMO NOT NULL)"
'on exécute la commande
cmd.ExecuteNonQuery()
'Fermer la connexion
Cnx.Close()
End
Sub
Private
Sub
MonthCalendar1_DateChanged(
ByVal
sender
As
System.Object,
ByVal
e
As
System.Windows.Forms.DateRangeEventArgs)
Handles
MonthCalendar1.DateChanged
If
e.Start.ToLongDateString = Format(DateString,
"Long Date"
)
Then
tssl2.Text = e.Start.ToLongDateString
Else
tssl2.Text = e.End.ToLongDateString
End
If
End
Sub
Private
Sub
MonthCalendar1_DateSelected(
ByVal
sender
As
Object
,
ByVal
e
As
System.Windows.Forms.DateRangeEventArgs)
Handles
MonthCalendar1.DateSelected
Dim
NomB
As
String
= Application.StartupPath &
"\Calendrier.mdb"
If
e.Start.ToLongDateString = Format(DateString,
"Long Date"
)
Then
CreateTable()
Else
CreateTable()
End
If
End
Sub
Private
Sub
Form1_Load(
ByVal
sender
As
System.Object,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Loadtssl2.Text = Format(DateString,
"Long Date"
)
Dim
NomB
As
String
= Application.StartupPath &
"\Calendrier.mdb"
If
Len(Dir(Application.StartupPath &
"\Calendrier.mdb"
, FileAttribute.Normal)) <> 0
Then
tssl1.Text =
"Prêt"
Else
CreateBDD()
tssl1.Text =
"Base créer"
End
If
End
SubEnd
Class
Voila j'utilise ceci pour le debut de mon programme d'agenda
Mais voila que je recois toujours cette mauditte erreur
Erreur de syntaxe dans l'instruction CREATE TABLE.
Exception non gerer
Pourtant je me sert de cette meme fonction ailleur et ca fonctionne
est ce que quelqu'un peut me dire ce que je fais qui ne va pas
DanMor
Afficher la suite