je veux ajouter un champs Mémo dans une table Access, par une procédure VB6,
mon code = .Columns.Append TxtChamps.Text, adMemo, et cela BEUG sur adMemo
pouvez-vous m'indiquer le bon code ?
Ensuite pour valider, mon code =cat.Tables.Append tbl et cela Beug avec un
message la table existe déjà, si je supprime cette ligne ma table n'est pas
modifiée
où est l'erreur ?
Bonsoir, vous ne pouvez pas modifier la structure d'une db déjà existante par cette technique, ce n'est possible que pour un recordset déconnecté voir : http://faq.vb.free.fr/index.php?question1 Vous devez modifier la structure d'une db existante via adox. Exemple : '------------------------------------------------------------------------------------------------------------ Dim tbl As ADOX.Table Dim cat As ADOX.Catalog
Set tbl = New ADOX.Table Set cat = New ADOX.Catalog cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=CheminDeVotreDBEtSonNom;" Set tbl = cat.Tables.Item("NomDeVotreTable") tbl.Columns.Append "FieldMemo", adLongVarWChar Set tbl = Nothing Set cat = Nothing '------------------------------------------------------------------------------------------------------------
@+Quaz
-- This is an automatic signature of MesNews. Site : http://mesnews.no-ip.com
Bonsoir,
vous ne pouvez pas modifier la structure d'une db déjà existante par
cette technique, ce n'est possible que pour un recordset déconnecté
voir : http://faq.vb.free.fr/index.php?question1
Vous devez modifier la structure d'une db existante via adox.
Exemple :
'------------------------------------------------------------------------------------------------------------
Dim tbl As ADOX.Table
Dim cat As ADOX.Catalog
Set tbl = New ADOX.Table
Set cat = New ADOX.Catalog
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=CheminDeVotreDBEtSonNom;"
Set tbl = cat.Tables.Item("NomDeVotreTable")
tbl.Columns.Append "FieldMemo", adLongVarWChar
Set tbl = Nothing
Set cat = Nothing
'------------------------------------------------------------------------------------------------------------
@+Quaz
--
This is an automatic signature of MesNews.
Site : http://mesnews.no-ip.com
Bonsoir, vous ne pouvez pas modifier la structure d'une db déjà existante par cette technique, ce n'est possible que pour un recordset déconnecté voir : http://faq.vb.free.fr/index.php?question1 Vous devez modifier la structure d'une db existante via adox. Exemple : '------------------------------------------------------------------------------------------------------------ Dim tbl As ADOX.Table Dim cat As ADOX.Catalog
Set tbl = New ADOX.Table Set cat = New ADOX.Catalog cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=CheminDeVotreDBEtSonNom;" Set tbl = cat.Tables.Item("NomDeVotreTable") tbl.Columns.Append "FieldMemo", adLongVarWChar Set tbl = Nothing Set cat = Nothing '------------------------------------------------------------------------------------------------------------
@+Quaz
-- This is an automatic signature of MesNews. Site : http://mesnews.no-ip.com
JCM
Bonjour et merci pour votre réponse
Néanmoins le champs s'ajoute mais cela beug pour les propriétés, sur la ligne set.parentCatalogÊt, j'ai le message d'erreur : l'opération demandée n'est pas autorisée dans ce contexte.
Je ne vois pas ou est le problème, voici mon code :
Public Function ModifierTable(cat As ADOX.Catalog, TableName As String) As Boolean ' Ajout du champs Set cat = New ADOX.Catalog Set col = New ADOX.Column Set tbl = New ADOX.Table cat.ActiveConnection = ADOcnx
Set tbl = cat.Tables.Item(TableSelection) With tbl If OptNumerique.Value = True Then .Columns.Append TxtChamps.Text, adInteger End If If OptTexte.Value = True Then .Columns.Append TxtChamps.Text, adVarWChar, 150 End If If OptMemo.Value = True Then .Columns.Append "FieldMemo", adLongVarWChar End If Set col = tbl.Columns(TxtChamps.Text) With col Set .ParentCatalog = cat If OptNulOui.Value = True Then .Properties("Nullable") = True Else .Properties("Nullable") = False End If If OptVideOui.Value = True Then .Properties("Jet OLEDB:Allow Zero Length") = True Else .Properties("Jet OLEDB:Allow Zero Length") = False End If End With End With Set col = Nothing Set cat = Nothing Set tbl = Nothing End Function
Bonsoir, vous ne pouvez pas modifier la structure d'une db déjà existante par cette technique, ce n'est possible que pour un recordset déconnecté voir : http://faq.vb.free.fr/index.php?question1 Vous devez modifier la structure d'une db existante via adox. Exemple : '------------------------------------------------------------------------------------------------------------ Dim tbl As ADOX.Table Dim cat As ADOX.Catalog
Set tbl = New ADOX.Table Set cat = New ADOX.Catalog cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=CheminDeVotreDBEtSonNom;" Set tbl = cat.Tables.Item("NomDeVotreTable") tbl.Columns.Append "FieldMemo", adLongVarWChar Set tbl = Nothing Set cat = Nothing '------------------------------------------------------------------------------------------------------------
@+Quaz
-- This is an automatic signature of MesNews. Site : http://mesnews.no-ip.com
Bonjour et merci pour votre réponse
Néanmoins le champs s'ajoute mais cela beug pour les propriétés, sur la
ligne set.parentCatalogÊt, j'ai le message d'erreur : l'opération demandée
n'est pas autorisée dans ce contexte.
Je ne vois pas ou est le problème, voici mon code :
Public Function ModifierTable(cat As ADOX.Catalog, TableName As String) As
Boolean
' Ajout du champs
Set cat = New ADOX.Catalog
Set col = New ADOX.Column
Set tbl = New ADOX.Table
cat.ActiveConnection = ADOcnx
Set tbl = cat.Tables.Item(TableSelection)
With tbl
If OptNumerique.Value = True Then
.Columns.Append TxtChamps.Text, adInteger
End If
If OptTexte.Value = True Then
.Columns.Append TxtChamps.Text, adVarWChar, 150
End If
If OptMemo.Value = True Then
.Columns.Append "FieldMemo", adLongVarWChar
End If
Set col = tbl.Columns(TxtChamps.Text)
With col
Set .ParentCatalog = cat
If OptNulOui.Value = True Then
.Properties("Nullable") = True
Else
.Properties("Nullable") = False
End If
If OptVideOui.Value = True Then
.Properties("Jet OLEDB:Allow Zero Length") = True
Else
.Properties("Jet OLEDB:Allow Zero Length") = False
End If
End With
End With
Set col = Nothing
Set cat = Nothing
Set tbl = Nothing
End Function
Bonsoir,
vous ne pouvez pas modifier la structure d'une db déjà existante par
cette technique, ce n'est possible que pour un recordset déconnecté
voir : http://faq.vb.free.fr/index.php?question1
Vous devez modifier la structure d'une db existante via adox.
Exemple :
'------------------------------------------------------------------------------------------------------------
Dim tbl As ADOX.Table
Dim cat As ADOX.Catalog
Set tbl = New ADOX.Table
Set cat = New ADOX.Catalog
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=CheminDeVotreDBEtSonNom;"
Set tbl = cat.Tables.Item("NomDeVotreTable")
tbl.Columns.Append "FieldMemo", adLongVarWChar
Set tbl = Nothing
Set cat = Nothing
'------------------------------------------------------------------------------------------------------------
@+Quaz
--
This is an automatic signature of MesNews.
Site : http://mesnews.no-ip.com
Néanmoins le champs s'ajoute mais cela beug pour les propriétés, sur la ligne set.parentCatalogÊt, j'ai le message d'erreur : l'opération demandée n'est pas autorisée dans ce contexte.
Je ne vois pas ou est le problème, voici mon code :
Public Function ModifierTable(cat As ADOX.Catalog, TableName As String) As Boolean ' Ajout du champs Set cat = New ADOX.Catalog Set col = New ADOX.Column Set tbl = New ADOX.Table cat.ActiveConnection = ADOcnx
Set tbl = cat.Tables.Item(TableSelection) With tbl If OptNumerique.Value = True Then .Columns.Append TxtChamps.Text, adInteger End If If OptTexte.Value = True Then .Columns.Append TxtChamps.Text, adVarWChar, 150 End If If OptMemo.Value = True Then .Columns.Append "FieldMemo", adLongVarWChar End If Set col = tbl.Columns(TxtChamps.Text) With col Set .ParentCatalog = cat If OptNulOui.Value = True Then .Properties("Nullable") = True Else .Properties("Nullable") = False End If If OptVideOui.Value = True Then .Properties("Jet OLEDB:Allow Zero Length") = True Else .Properties("Jet OLEDB:Allow Zero Length") = False End If End With End With Set col = Nothing Set cat = Nothing Set tbl = Nothing End Function
Bonsoir, vous ne pouvez pas modifier la structure d'une db déjà existante par cette technique, ce n'est possible que pour un recordset déconnecté voir : http://faq.vb.free.fr/index.php?question1 Vous devez modifier la structure d'une db existante via adox. Exemple : '------------------------------------------------------------------------------------------------------------ Dim tbl As ADOX.Table Dim cat As ADOX.Catalog
Set tbl = New ADOX.Table Set cat = New ADOX.Catalog cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=CheminDeVotreDBEtSonNom;" Set tbl = cat.Tables.Item("NomDeVotreTable") tbl.Columns.Append "FieldMemo", adLongVarWChar Set tbl = Nothing Set cat = Nothing '------------------------------------------------------------------------------------------------------------
@+Quaz
-- This is an automatic signature of MesNews. Site : http://mesnews.no-ip.com