Hi guy,
would you help me, how to create table (ACCESS) with primary key in visual Basic 6?
Set catNewDB = CreateObject("ADOX.Catalog")
catNewDB.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sDatabasetocreate & _
";Jet OLEDB:Engine Type=5;"
' Engine Type=5 = Access 2000 Database
' Engine Type=4 = Access 97 Database
Set catNewDB = Nothing
Set catDB = CreateObject("ADOX.Catalog")
' Open the catalog
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sDatabasetocreate
' Create new Table
Set tblNew = CreateObject("ADOX.Table")
tblNew.Name = "DataPeserta"
Set col = CreateObject("ADOX.Column")
With col
.ParentCatalog = catDB
.Type = adVarWChar
.Name = "NOPOL"
.Properties("Description") = "I am the Description " & _
"for the column"
End With
tblNew.Columns.Append col
' Now add the rest of the columns
With tblNew
' Create fields and append them to the
' Columns collection of the new Table object.
With .Columns
.Append "NOMBER", adVarWChar
.Append "NAME", adVarWChar
.Append "ISSUE_ATE", adDate
.Append "BIRTH_DATE", adDate
.Append "GAJI", adSingle
End With