Via een ADODB.Command voeg ik een tabel toe aan een bestaande database, dit werkt alleen wordt er geen primary key gezet op de colom die ik aanmaak terwijl dat wel aangeef. De colom blijft ook NULL accepteren en ook dat wordt niet aangegeven.
Hier de code, in vb6 en er wordt naar sql2000 geconnect:
Hier de code, in vb6 en er wordt naar sql2000 geconnect:
code:
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
| Dim strConnect As String
strConnect = _
"Provider=SQLOLEDB.1;" & _
"Persist Security Info=False;" & _
"User ID=userid;" & _
"Password=password" & _
"Initial Catalog=catalognaam;" & _
"Data Source=SQLDOOS01"
On Error GoTo ErrorHandler
Dim oSQL As New ADODB.Command
Set oSQL = New ADODB.Command
Debug.Print "Activating connection.."
oSQL.ActiveConnection = strConnect
Debug.Print "Dropping table.."
oSQL.CommandText = "DROP TABLE tbl_AccountInformatie"
oSQL.Execute
Debug.Print "Creating table.."
oSQL.CommandText = "CREATE TABLE [dbo].[tbl_AccountInformatie] ([AccountID] [int]) ON [PRIMARY]"
oSQL.Execute
'oSQL.CommandText = "CREATE INDEX [AccountID] ON [dbo].[tbl_AccountInformatie]([AccountID]) ON [PRIMARY]"
'oSQL.Execute
Set oSQL = Nothing
Debug.Print "Done.."
On Error GoTo 0
Exit Sub
ErrorHandler:
Debug.Print Err.Number & ":" & Err.Description
Resume Next |