Thursday, March 22, 2012

Detecting SQL Server 2000 vs 2005 instance

I have the following two questions:
1) I can use the ListAvailableSQLServers methods in SQL-DMO to get a list of
all the available sql servers (in the form of Namelist) but how can I detect
which ones are SQL Server 2000/MSDE 2000 instances and which ones are 2005
instances programmatically either using VB6 or C#?
2) If I have a few machines in my network and one of them has an instance
called
"mycomputer/myinstance", the method "ListAvailableSQLServers" does not list
it. Could that be related to the windows firewall being turned on?
ANeelimaYou'd want to use smo instead of dmo to interact with both sql2k5 and sql2k.
Take a look at Server.PingSqlServerVersion() method under
Microsoft.SqlServer.Management.Smo namespace.
-oj
"ANeelima" <neelima@.newsgroups.nospam> wrote in message
news:B178E81E-C9DA-46FC-B0FB-504537B030D3@.microsoft.com...
>I have the following two questions:
> 1) I can use the ListAvailableSQLServers methods in SQL-DMO to get a list
> of
> all the available sql servers (in the form of Namelist) but how can I
> detect
> which ones are SQL Server 2000/MSDE 2000 instances and which ones are 2005
> instances programmatically either using VB6 or C#?
> 2) If I have a few machines in my network and one of them has an instance
> called
> "mycomputer/myinstance", the method "ListAvailableSQLServers" does not
> list
> it. Could that be related to the windows firewall being turned on?
> --
> ANeelima|||Hi,
Thanks for your post!
From your description, I understand that:
Your 1st question was that you wanted to detect each SQL Server version
corresponding to each SQL Server instances.
Your 2nd question was that you found you couldn't get the list of all SQL
Server instances in your network via ListAvailableSQLServers.
If I have misunderstood, please let me know.
For the first question, I recommend you:
1) Create a SQLDMO.SQLServer object.
2) Connect to the SQL Server by server name.
3) Get the version information by the property SQLServer.VersionString or
SQLServer.VersionMajor.
For the second question, I recommend you check your network settings and
ensure your application machine can access any SQL Server instance.
I write a sample and get the named instances that my machine can access in
network:
SQLDMO.Application app = new SQLDMO.ApplicationClass();
SQLDMO.NameList nl = app.ListAvailableSQLServers();
for (int i = 0; i < nl.Count; ++i)
{
string s = nl.Item(i);
this.label1.Text += s + "\n";
}
If you have any other concerns, please feel free to let me know. It's my
pleasure to be of assistance.
+++++++++++++++++++++++++++
Charles Wang
Microsoft Online Partner Support
+++++++++++++++++++++++++++
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
Business-Critical Phone Support (BCPS) provides you with technical phone
support at no charge during critical LAN outages or "business down"
situations. This benefit is available 24 hours a day, 7 days a week to all
Microsoft technology partners in the United States and Canada.
This and other support options are available here:
BCPS:
https://partner.microsoft.com/US/te...erview/40010469
Others:
https://partner.microsoft.com/US/te...upportoverview/
If you are outside the United States, please visit our International
Support page:
http://support.microsoft.com/defaul...rnational.aspx.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.|||Thanks.
My application is in VB6.0. How can I use SMO from VB6.0? I can't
seem to find it in the list of references in VB6.0. What is the reference
name?
ANeelima
"oj" wrote:

> You'd want to use smo instead of dmo to interact with both sql2k5 and sql2
k.
> Take a look at Server.PingSqlServerVersion() method under
> Microsoft.SqlServer.Management.Smo namespace.
> --
> -oj
>
> "ANeelima" <neelima@.newsgroups.nospam> wrote in message
> news:B178E81E-C9DA-46FC-B0FB-504537B030D3@.microsoft.com...
>
>|||Well, I was hoping that I don't have to connect to the server to get the
version name.
I wanted to simply use ListAvailableSQLServers, get the namelist, loop
through the servers and find the version without connecting.
It appears like I can do that with SMO using something like
----
DataTable dataTable = SmoApplication.EnumAvailableSqlServers();
foreach (DataRow dataRow in dataTable.Rows )
{
row.Append(
"Server: " + dataRow["Name"] + " Version: " + dataRow["Version"]);
}
Console.WriteLine(row.ToString());
----
--
But I can't do that with SQLDMO.
My application is in VB6.0 and if I need to use SMO in VB6.0 how can I do
that?
ANeelima
"Charles Wang[MSFT]" wrote:

> Hi,
> Thanks for your post!
> From your description, I understand that:
> Your 1st question was that you wanted to detect each SQL Server version
> corresponding to each SQL Server instances.
> Your 2nd question was that you found you couldn't get the list of all SQL
> Server instances in your network via ListAvailableSQLServers.
> If I have misunderstood, please let me know.
> For the first question, I recommend you:
> 1) Create a SQLDMO.SQLServer object.
> 2) Connect to the SQL Server by server name.
> 3) Get the version information by the property SQLServer.VersionString or
> SQLServer.VersionMajor.
> For the second question, I recommend you check your network settings and
> ensure your application machine can access any SQL Server instance.
> I write a sample and get the named instances that my machine can access in
> network:
> SQLDMO.Application app = new SQLDMO.ApplicationClass();
> SQLDMO.NameList nl = app.ListAvailableSQLServers();
> for (int i = 0; i < nl.Count; ++i)
> {
> string s = nl.Item(i);
> this.label1.Text += s + "\n";
> }
> If you have any other concerns, please feel free to let me know. It's my
> pleasure to be of assistance.
> +++++++++++++++++++++++++++
> Charles Wang
> Microsoft Online Partner Support
> +++++++++++++++++++++++++++
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ========================================
=============
> Business-Critical Phone Support (BCPS) provides you with technical phone
> support at no charge during critical LAN outages or "business down"
> situations. This benefit is available 24 hours a day, 7 days a week to all
> Microsoft technology partners in the United States and Canada.
> This and other support options are available here:
> BCPS:
> https://partner.microsoft.com/US/te...erview/40010469
> Others:
> https://partner.microsoft.com/US/te...upportoverview/
> If you are outside the United States, please visit our International
> Support page:
> http://support.microsoft.com/defaul...rnational.aspx.
> ========================================
=============
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>|||As long as SQL Browser service is online (and it should), you don't have to
connect to the SQL instances to check their versions. You can send a packet
to UDP 1434 and get the version info in the reply. If you don't want to
program sockets firectly, you can leverage the output of SQLPing.exe and
parse the result text for the instance names and their versions. You can fin
d
SQLPing.exe via Google.
Linchi
"ANeelima" wrote:

> I have the following two questions:
> 1) I can use the ListAvailableSQLServers methods in SQL-DMO to get a list
of
> all the available sql servers (in the form of Namelist) but how can I dete
ct
> which ones are SQL Server 2000/MSDE 2000 instances and which ones are 2005
> instances programmatically either using VB6 or C#?
> 2) If I have a few machines in my network and one of them has an instance
> called
> "mycomputer/myinstance", the method "ListAvailableSQLServers" does not lis
t
> it. Could that be related to the windows firewall being turned on?
> --
> ANeelima|||Unfortunately, SMO doesn't support COM. You might want to take a look at the
updated DMO.
"Microsoft SQL Server 2005 Backward Compatibility Components
The SQL Server Backward Compatibility package includes the latest versions
of Data Transformation Services 2000 runtime (DTS), SQL Distributed
Management Objects (SQL-DMO), Decision Support Objects (DSO), and SQL
Virtual Device Interface (SQLVDI). These versions have been updated for
compatibility with SQL Server 2005 and include all fixes shipped through SQL
Server 2000 SP4."
http://www.microsoft.com/downloads/...&displaylang=en
-oj
"ANeelima" <neelima@.newsgroups.nospam> wrote in message
news:E9A07FEA-8F2F-40C5-BADE-599D41B88FB4@.microsoft.com...[vbcol=seagreen]
> Thanks.
> My application is in VB6.0. How can I use SMO from VB6.0? I can't
> seem to find it in the list of references in VB6.0. What is the reference
> name?
>
> --
> ANeelima
>
> "oj" wrote:
>|||Hi,
Thanks for your response.
SMO is included in SQL Server 2005. You can find the assemblies in:
"C:\Program Files\Microsoft SQL
Server\90\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll",
"C:\Program Files\Microsoft SQL
Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll",
"C:\Program Files\Microsoft SQL
Server\90\SDK\Assemblies\Microsoft.SqlServer.SmoEnum.dll",
"C:\Program Files\Microsoft SQL
Server\90\SDK\Assemblies\Microsoft.SqlServer.SqlEnum.dll"
You can directly add the references in VS.NET 2003/2005.
The assemblies names are:
Microsoft.SqlServer.ConnectionInfo
Microsoft.SqlServer.Smo
Microsoft.SqlServer.SmoEnum
Microsoft.SqlServer.SqlEnum
If you want to use SMO in VB6, I recommend you use VS.Net 2003/2005 to wrap
the assembly into a COM library.
It's easy to realize this wrap in VS.Net 2003/2005.
You can refer to this article:
Can I Interest You in 5000 Classes?
Using the Full .NET Framework from Visual Basic 6
http://msdn.microsoft.com/vbrun/vbf...ibrary/en-us/dv
_vstechart/html/VB5000Cl.asp
If you have any other concerns, please feel free to let me know. It's my
pleasure to be of assistance.
+++++++++++++++++++++++++++
Charles Wang
Microsoft Online Partner Support
+++++++++++++++++++++++++++
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
Business-Critical Phone Support (BCPS) provides you with technical phone
support at no charge during critical LAN outages or "business down"
situations. This benefit is available 24 hours a day, 7 days a week to all
Microsoft technology partners in the United States and Canada.
This and other support options are available here:
BCPS:
https://partner.microsoft.com/US/te...erview/40010469
Others:
https://partner.microsoft.com/US/te...upportoverview/
If you are outside the United States, please visit our International
Support page:
http://support.microsoft.com/defaul...rnational.aspx.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi
How do you use the assemblies SMO if you don't install sql2005?
I have a web application in vs net 2003, and i have use de object
SQLServer for print a list of databases, tables, etc of other server
with sql2005
but in my server i don't have SQL2005, exist any client for that?
thanks
Charles Wang[MSFT] wrote:[vbcol=seagreen]
> Hi,
> Thanks for your response.
> SMO is included in SQL Server 2005. You can find the assemblies in:
> "C:\Program Files\Microsoft SQL
> Server\90\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll",
> "C:\Program Files\Microsoft SQL
> Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll",
> "C:\Program Files\Microsoft SQL
> Server\90\SDK\Assemblies\Microsoft.SqlServer.SmoEnum.dll",
> "C:\Program Files\Microsoft SQL
> Server\90\SDK\Assemblies\Microsoft.SqlServer.SqlEnum.dll"
> You can directly add the references in VS.NET 2003/2005.
> The assemblies names are:
> Microsoft.SqlServer.ConnectionInfo
> Microsoft.SqlServer.Smo
> Microsoft.SqlServer.SmoEnum
> Microsoft.SqlServer.SqlEnum
> If you want to use SMO in VB6, I recommend you use VS.Net 2003/2005 to wra
p
> the assembly into a COM library.
> It's easy to realize this wrap in VS.Net 2003/2005.
> You can refer to this article:
> Can I Interest You in 5000 Classes?
> Using the Full .NET Framework from Visual Basic 6
> [url]http://msdn.microsoft.com/vbrun/vbfusion/default.aspx?pull=/library/en-us/dv[/ur
l]
> _vstechart/html/VB5000Cl.asp
> If you have any other concerns, please feel free to let me know. It's my
> pleasure to be of assistance.
> +++++++++++++++++++++++++++
> Charles Wang
> Microsoft Online Partner Support
> +++++++++++++++++++++++++++
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ========================================
=============
> Business-Critical Phone Support (BCPS) provides you with technical phone
> support at no charge during critical LAN outages or "business down"
> situations. This benefit is available 24 hours a day, 7 days a week to all
> Microsoft technology partners in the United States and Canada.
> This and other support options are available here:
> BCPS:
> https://partner.microsoft.com/US/te...erview/40010469
> Others:
> https://partner.microsoft.com/US/te...upportoverview/
> If you are outside the United States, please visit our International
> Support page:
> http://support.microsoft.com/defaul...rnational.aspx.
> ========================================
=============
> This posting is provided "AS IS" with no warranties, and confers no rights.[/vbcol
]|||Hi
How do you use the assemblies SMO if you don't install sql2005?
I have a web application in vs net 2003, and i have use de object
SQLServer for print a list of databases, tables, etc of other server
with sql2005
but in my server i don't have SQL2005, exist any client for that?
thanks
Charles Wang[MSFT] wrote:[vbcol=seagreen]
> Hi,
> Thanks for your response.
> SMO is included in SQL Server 2005. You can find the assemblies in:
> "C:\Program Files\Microsoft SQL
> Server\90\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll",
> "C:\Program Files\Microsoft SQL
> Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll",
> "C:\Program Files\Microsoft SQL
> Server\90\SDK\Assemblies\Microsoft.SqlServer.SmoEnum.dll",
> "C:\Program Files\Microsoft SQL
> Server\90\SDK\Assemblies\Microsoft.SqlServer.SqlEnum.dll"
> You can directly add the references in VS.NET 2003/2005.
> The assemblies names are:
> Microsoft.SqlServer.ConnectionInfo
> Microsoft.SqlServer.Smo
> Microsoft.SqlServer.SmoEnum
> Microsoft.SqlServer.SqlEnum
> If you want to use SMO in VB6, I recommend you use VS.Net 2003/2005 to wra
p
> the assembly into a COM library.
> It's easy to realize this wrap in VS.Net 2003/2005.
> You can refer to this article:
> Can I Interest You in 5000 Classes?
> Using the Full .NET Framework from Visual Basic 6
> [url]http://msdn.microsoft.com/vbrun/vbfusion/default.aspx?pull=/library/en-us/dv[/ur
l]
> _vstechart/html/VB5000Cl.asp
> If you have any other concerns, please feel free to let me know. It's my
> pleasure to be of assistance.
> +++++++++++++++++++++++++++
> Charles Wang
> Microsoft Online Partner Support
> +++++++++++++++++++++++++++
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ========================================
=============
> Business-Critical Phone Support (BCPS) provides you with technical phone
> support at no charge during critical LAN outages or "business down"
> situations. This benefit is available 24 hours a day, 7 days a week to all
> Microsoft technology partners in the United States and Canada.
> This and other support options are available here:
> BCPS:
> https://partner.microsoft.com/US/te...erview/40010469
> Others:
> https://partner.microsoft.com/US/te...upportoverview/
> If you are outside the United States, please visit our International
> Support page:
> http://support.microsoft.com/defaul...rnational.aspx.
> ========================================
=============
> This posting is provided "AS IS" with no warranties, and confers no rights.[/vbcol
]

No comments:

Post a Comment