|
-
January 28th, 2000, 06:42 AM
#1
Cerating Table using SQL OLEDB.DLL
Hi Friends,
Can anybody help me to create tables using SQL DMO from VB with Primary Key and all database objects.
-
January 28th, 2000, 07:00 AM
#2
Re: Cerating Table using SQL OLEDB.DLL
here is a sample that uses SQLOLE. The methods are the same in SQLDMO.
Just replace SQLOLE with SQLDMO.
Tested with SQLServer 6.5 on NT 4 VB 6
Dim s as SQLOLE.SQLServer
set s = new SQLOLE.SQLServer
s.Connect "yourserver", "sa", ""
Dim t as new SQLOLE.Table
Dim col as new SQLOLE.Column
col.Name = "test"
col.Datatype = "varchar"
col.Length = 10
col.AllowNulls = false
t.Columns.Add col
set col = new SQLOLE.Column
col.Name = "test2"
col.Datatype = "varchar"
col.Length = 5
col.AllowNulls = true
t.Columns.Add col
t.Name = "mytesttable"
Dim k as new SQLOLE.Key
k.Clustered = true
k.Type = SQLOLEKey_Primary
k.KeyColumns.Add "test"
t.Keys.Add k
't.PrimaryKey = "test"
s.Databases("einzeltest").Tables.Add t
s.Disconnect
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|