Hi!
I have the following snippet that gives the name of the sql servers
installed:
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
'just list local servers, set to false if you want to see all
servers
Dim dataTable = SmoApplication.EnumAvailableSqlServers(False)
lstServers.ValueMember = "Name"
lstServers.DataSource = dataTable
End Sub
We have only 2 sql server where the client data reside, but then we
have instances of sql installed in other machines.
I only want to be able to show in my listbox for the user to choose,
those with the sql part in their name.
e.g. tg-ny-sql001
tg-ny-sql002
so the condition would be if the name has sql in it show it in the
listbox.
How can I achieve this with VB 2008 and using SQL Server 2000 in the
first server and SQL Server 2005 in the second server?
Thanks in advanced!
Tammy 4 2084
Tammy,
In my idea is that what you need. There is as well a tip for a sqlservers on
one machine. http://www.vb-tips.com/ListComputersAPI.aspx
Cor
<jt*****@gmail.comschreef in bericht
news:50**********************************@p25g2000 hsf.googlegroups.com...
Hi!
I have the following snippet that gives the name of the sql servers
installed:
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
'just list local servers, set to false if you want to see all
servers
Dim dataTable = SmoApplication.EnumAvailableSqlServers(False)
lstServers.ValueMember = "Name"
lstServers.DataSource = dataTable
End Sub
We have only 2 sql server where the client data reside, but then we
have instances of sql installed in other machines.
I only want to be able to show in my listbox for the user to choose,
those with the sql part in their name.
e.g. tg-ny-sql001
tg-ny-sql002
so the condition would be if the name has sql in it show it in the
listbox.
How can I achieve this with VB 2008 and using SQL Server 2000 in the
first server and SQL Server 2005 in the second server?
Thanks in advanced!
Tammy
Cor,
Thank you for your reply, but that does not help me.
I have one listbox that should show me only the sql server that i want
Then i have another listbox which will show me the databases from the
server selected in the previous listbox.
Then I have a third listbox with specific book titles from the
databases selected above.
Here is the code that I have for now:
Imports System
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Data
Imports Microsoft.SqlServer
Imports Microsoft.SqlServer.Server
Imports Microsoft.SqlServer.Management
Imports Microsoft.SqlServer.Management.Smo
Public Class Form1
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
'just list local servers, set to false if you want to see all
servers
Dim dataTable = SmoApplication.EnumAvailableSqlServers(False)
lstServers.ValueMember = "Name"
lstServers.DataSource = dataTable
End Sub
Private Sub lstServers_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lstServers.SelectedIndexChanged
lstDatabases.Items.Clear()
If lstServers.SelectedIndex <-1 Then
Dim serverName As String =
lstServers.SelectedValue.ToString()
Dim server As Server = New Server(serverName)
Try
For Each database As Database In server.Databases
lstDatabases.Items.Add(database.Name)
Next
Catch ex As Exception
Dim exception As String = ex.Message
End Try
End If
End Sub
Private Sub lstDatabases_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lstDatabases.Click
lstFileSets.Items.Clear()
Dim cn As New SqlClient.SqlConnection()
Dim cm As New SqlClient.SqlCommand()
Dim dr As SqlClient.SqlDataReader
With cn
.ConnectionString = "Data Source=" &
lstServers.SelectedValue & ";Initial Catalog=" &
lstDatabases.SelectedValue & ";Integrated Security=SSPI"
.Open()
End With
With cm
.CommandText = "usp_Search_book_titles"
.CommandType = CommandType.StoredProcedure
.Connection = cn
.Parameters.AddWithValue("@Matter",
lstDatabases.SelectedItem)
End With
dr = cm.ExecuteReader(CommandBehavior.CloseConnection)
While dr.Read
lstFileSets.Items.Add(dr.Item(0))
End While
dr.Close()
End Sub
End Class
Unfortunately I need to only show the 2 sql servers and NOT all the
instances in which sql is installed.
sql server names:
e.g. tg-ny-sql001
tg-ny-sql002
I tried incorporating what you suggested but I get a ton of errors. I
am using VB 2008.
Thanks a lot in advanced!!!!
Tammy
Tammy,
Have a look at your subject, I see not any relation with what you write and
that subject, I was answering on your subject.
If you do not step one first the second step can never be done.
Cor
Cor,
As I have it now..it does work, but I do not want the users to see the
rest of the available instances of SQL installed throughout the
network. They only need to see the 2 servers from which they will
select the database etc.
Thanks!
Sorry I am new to VB! :-(((
Tammy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gregory |
last post by:
Hello,
I'm trying to do the above in order to process an image and return the
result to an html image control. It fails and my key suspects are either
the variable that I'm passing in -...
|
by: John Dewbert |
last post by:
*** post for FREE via your newsreader at post.newsfeed.com ***
Hello,
I have trouble passing a folder object (from a FileSystemObject) to a sub
procedure.
Consider the following code:
...
|
by: Rob Meade |
last post by:
Hi all,
At work we have 2 servers in a cluster for our web apps.
One problem we have experienced (along with many others!) - is that if a
user is logged into one of the applications on server...
|
by: Richard |
last post by:
**** Post for FREE via your newsreader at post.usenet.com ****
HI,
I am working on a project where I need to input data to a (local) HTML page
using multiple form elements, such as text,...
|
by: JJ |
last post by:
Hi,
What's the preferred way to pass variables around to different pages now?
Or if my reading servers me right they are retained in memory for the life of
the app, correct? How do I access...
|
by: BrendanMcPherson |
last post by:
Hello,
Im try to do some tricks to help make a "Search Many Sites from One
Location".
http://www.act.org.au/b_nexus.htm
What I have decided to do is this:
1. You can choose which site you...
|
by: Torben Laursen |
last post by:
Hi
I am trying to find find the sqlserver express that is running on my
computer using:
DataTable dtSQLServers = SmoApplication.EnumAvailableSqlServers(false);
It returns one row that holds...
|
by: Mike H |
last post by:
I can't seem to figure out the right thing to search on, so I thought
I'd just provide an example and see if someone can point me to some
tips.
What I have is an Automation Server that has a...
|
by: alan.limebeer |
last post by:
I'm writing a quick and dirty admin tool to check 308 servers for the
Last Modified date of a specific file that exists in the same place on
all 308 servers. Using the System.IO namespace objects...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |