Tuesday, November 16, 2004

SQL DMO - Distributed Management Objects

Dim objsqlserver As New SQLDMO.SQLServer

Private Sub Command1_Click()

objsqlserver.LoginTimeout = 30
objsqlserver.Connect "SERVER_Name", "sa", "sa"
MsgBox "Connected!!"
End Sub

Private Sub Command2_Click()
Dim TestTable As SQLDMO.Table
Dim colAge As New SQLDMO.Column

colAge.Name = "Age"
colAge.Datatype = "char"
colAge.Length = 10
colAge.AllowNulls = True
Set TestTable = objsqlserver.Databases("DB_Name").Tables("Test_Table")
TestTable.BeginAlter
TestTable.Columns.Add colAge
TestTable.DoAlter
End Sub

No comments: