C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







how to close and disconnect SMO objects using ironpython


Posted Date: 10 Jul 2007    Resource Type: Articles    Category: .NET Framework

Posted By: Sunil Pottumuttu       Member Level: Silver
Rating:     Points: 10



The resource has not been reviewed by Editors yet. Readers are advised to use their best judgement before accessing this resource.
This resource will be reviewed shortly.
If you think this resource contain inappropriate content, please report to webmaster.




SMO is used for database administration for SQLSERVER 2005.

SQL Server 2000 supports a COM-based object model, called SQL-DMO, which can be used to programmatically manage the SQL Servers. Enterprise Manager uses this API to manage SQL Server. SQL Server 2005 replaces SQL-DMO

The import name spaces assemblies for using SMO are
1.Microsoft.SqlServer.Management.Smo
2.Microsoft.SqlServer.Management.Smo.Agent
3.Microsoft.SqlServer.Management.Smo.Broker
4.Microsoft.SqlServer.Management.Smo.Mail
5.Microsoft.SqlServer.Management.Smo.RegisteredServers
6.Microsoft.SqlServer.Management.Smo.Wmi


#####################################################################
#
# CLOSE AND DISCONNECT AN SMO OBJECT IN IRONPYTHON
#
#
######################################################################

import sys
import clr
sys.path.append(r"D:\Program Files\Microsoft SQL Server\90\SDK\Assemblies")
clr.AddReferenceToFile('Microsoft.SqlServer.Smo.dll')
#clr.AddReferenceToFile('Microsoft.SqlServer.SmoEnum.dll')
#clr.AddReferenceToFile('Microsoft.SqlServer.SqlEnum.dll')
clr.AddReferenceToFile('Microsoft.SqlServer.ConnectionInfo.dll')

from Microsoft.SqlServer.Management.Smo import *
from Microsoft.SqlServer.Management.Common import *

import Microsoft.SqlServer.Management.Smo as SMO
import Microsoft.SqlServer.Management.Common as Common

#
#
#connect to the sqlserver with IP adress, login, password
#NOTE : IPADDRESS,LOGIN,PASSWORD IN THIS EXAMPLE INTENTIONALLY MARKED AS xx
#
#

srv = SMO.Server("XXX.XX.XX.XX")
srv.ConnectionContext.LoginSecure = 0
srv.ConnectionContext.Login = "xx"
srv.ConnectionContext.Password = "xx"


#Disable automatic disconnection.
srv.ConnectionContext.AutoDisconnectMode = AutoDisconnectMode.NoAutoDisconnect

#Connect to the local, default instance of SQL Server.
srv.ConnectionContext.Connect()

#The actual connection is made when a property is retrieved.
print srv.Information.Version

#Disconnect explicitly.
srv.ConnectionContext.Disconnect()







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Demystifying Delegates and Events in C#
Previous Resource: Thread-safe events
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

accuconference

Contact Us    Privacy Policy    Terms Of Use