Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADOX and SQL Server... 2

Status
Not open for further replies.

lachie

Programmer
Jun 12, 2001
25
AU
I'm currently attempting to modify an existing table's schema. I've created a table, copied data into it, set a bunch of indexes and am in the process of wanting to set a primary key and set one of the fields to use the identity property.

VB code example...

Set pk = New Key
pk.Name = "PrimaryKey"
pk.Type = adKeyPrimary

For Each SourceColumn In SourceIndex.Columns
pk.Columns.Append SourceColumn.Name
Next SourceColumn

TargetTable.Keys.append pk


Can anybody help with this?

Thanks,

Lachlan.
 
Another way could be simply to execute the equivalent TSQL code against your connection to the database, i.e. something like this:

ALTER TABLE
WITH NOCHECK ADD
CONSTRAINT [PK_CONSTRAINTNAME] PRIMARY KEY NONCLUSTERED
(
[FIELD1],
[FIELD2]
) ON [PRIMARY]
GO

Thomas
 
Thanks for the info - I think this may be the way to do it. I've had some other problems with the ADOX / SQL Server OLE DB combination.

I'm not entirely convinced that ADOX works as well as microsoft says it does.

Thanks for your help,

lachlna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top