In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to call the COM object in C #, which is very detailed and has certain reference value. Friends who are interested must finish reading it.
C # calls COM object
We used to need to get the details of SQL Server many times in previous applications. In the past, we had to use API and inefficient ADO calls to get it. Now we have a new method, which is SQLDMO (SQL Distributed Management Objects,SQL distributed Management object), although it is not yet known and used. But SQLDMO provides many powerful features similar to getting information from SQL Server using code. For example, I'll just explain how to get a SQL Server list of your local network, how to connect to each SQL Server, and how to get a list of tables, stored procedures, and views in Server.
The SQLDMO object comes from SQLDMO.dll,SQLDMO.dll and is released with SQL Server2000. SQLDMO.dll itself is a COM object, so you must refer to it first in your .NET project, and the VS.NET integrated development environment will create all the necessary wrappers for COM. Note: if you use the "using SQLDMO;" statement to quote, you will get an error message.
After C # calls the COM object, you can easily use it.
All operations in this example use one or more of the following objects:
◆ SQLDMO.Application
◆ SQLDMO.SQLServer
◆ SQLDMO.Database
◆ SQLDMO.NameList
There are many objects available for operations such as data backup and recovery, but as an example, we will try to keep it as simple as possible to make it easy for you to enter the world of SQLDMO and browse its convenience.
Listing the SQL servers available on the local network is relatively simple. First, you need to reference the SQLDMO.Application object, and second, you must create an instance of the return value of the SQLDMO.Application.ListAvailableSQLServers () method. SQLDMO.NameList,SQLDMO.NameList is the COM collection of server names.
Remember: before you get used to C # calling the COM object, it's always scary for C # to call the COM object, but you'll be fine if you get used to it. Here is some sample code that populates the drop-down list box with a list of locally available SQL servers.
SQLDMO.ApplicationsqlApp=newSQLDMO.ApplicationClass (); SQLDMO.NameListsqlServers=sqlApp.ListAvailableSQLServers (); for (inti=0;i0) this.cboServers.SelectedIndex=0; else this.cboServers.Text= ""; / / get a list of all databases on the specified SQL server SQLDMO.ApplicationsqlApp=newSQLDMO.ApplicationClass (); SQLDMO.SQLServersrv=newSQLDMO.SQLServerClass (); srv.Connect (this.cboServers.SelectedItem.ToString (), this.txtUser.Text,this.txtPassword.Text) Foreach (SQLDMO.Databasedbinsrv.Databases) {if (db. Name calling null) this.cboDatabase.Items.Add (db.Name);} that's all about the article "how to call the COM object in C #". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.