Ok Carlos.
You can use:
1- ADO Command:
adoCMD=createObject('adodb.command')
adoCMD.ActiveConnection=...
adoCMD.CommandText="DROP DATABASE EXAMPLE"
adoCMD.Execute()
In this way, you send 1 command at time. Good control
2- SQL Automation:
Look in the help for Sql-DMO. This is the way to go if you want generate a script from the Sql Manager and simply execute it later (or if you want use GO and other things)
This is a example in VB
Private Sub cmd_Install_Click()
On Error GoTo ErrorHandler
Dim oSQLServer As New SQLDMO.SQLServer
Dim bConnected As Boolean
bConnected = False
oSQLServer.LoginTimeout = 30
If chk_Integrated.Value = 1 Then
oSQLServer.LoginSecure = True
oSQLServer.Connect txt_SQLServer.Text
Else
oSQLServer.Connect txt_SQLServer.Text, txt_Login.Text, _
txt_Password.Text
End If
' ... do installation ...
oSqlServer.ExecuteInmediate(filetostr('script.sql'))
oSQLServer.DisConnect
Exit Sub
ErrorHandler:
MsgBox (Err.Description)
If bConnected = True Then
oSQLServer.DisConnect
End If
End Sub
The Life is Beautiful!
Programmer in
Delphi, VS.NET
MCP