SQLDMO Help! URGENT!!!!

AlexCode

Well-known member
Joined
Jul 7, 2003
Messages
931
Location
Portugal
Hi...

Im developing a tool that, using SQLDMO, retrieves the objects from the available SQL Servers.

By now, I can retrieve anything but the relationships between tables!!

How can I do that?


Thanks!

Alex :p
 
Hi... thanks for the reply but...

If I connect to the Northwind DB, via SQLDMO, the Rules collection count = 0, but this DB have releationships between tables... :(
 
[VB]
static void OutputDbTableRelationships()
{
SQLServerClass sqlServer = new SQLServerClass();
sqlServer.LoginSecure = true;
sqlServer.Connect("localhost", null, null);
_Database db = sqlServer.Databases.Item("Northwind", null);
foreach(_Table table in db.Tables)
{
foreach(Key key in table.Keys)
{
if(key.Type != SQLDMO_KEY_TYPE.SQLDMOKey_Foreign)
continue;
Console.WriteLine("{0}.{1} references {2}.{3}", table.Name, key.KeyColumns.Item(1), key.ReferencedTable, key.ReferencedColumns.Item(1));
}
}
}
[/VB]
 
Yeah... works!!!
Thanks!

Just to add... I had it donne calling a system sp:

Dim result As SQLDMO.QueryResults = _
db.ExecuteWithResults("USE " & Me.m_DataBase.Name & " ; EXEC sp_helpconstraint " & Tables(t).Name & "")

Thanks again.

Alex :p
 
Back
Top