Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Know the USer ID and Initial catalog of SQL Server through VB

Posted on 2002-07-23
6
Medium Priority
?
234 Views
Last Modified: 2008-01-16
How can we know the User Name, Initial Catalog name of SQL server through visual basic 6.0 at runtime.

I want to populate the names of the database users and the initial catalog in the SQL Server database in combobox by passing the SERVER NAME.

0
Comment
Question by:mvarghese
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 7172066
If you have permissions to the Master database on SQL server you can use Select Name From Master.dbo.SysDatabases to get a list of database names. You can also use:

Select Name,DBName From Master.dbo.SysLogins

Which will give you the user names and their associated default database.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7172212
You can also use SQL-DMO to accomplish this.
0
 

Author Comment

by:mvarghese
ID: 7173437
Dear gencross,

Will you please send me a sample code on how to use the SQL-DMO object as you have said.

Thanks & regards,
Mathew
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Accepted Solution

by:
gencross earned 400 total points
ID: 7174152
This is code I use with SQL 7...

'First reference the Microsoft SQL-DMO Library

'Get a list of available SQL Servers, if you need to
Dim objSQL As SQLDMO.NameList
Set objSQL = SQLDMO.ListAvailableSQLServers
For X = 0 To objSQL.Count - 1
    Debug.Print objSQL(X)
Next

'Connect to server
Dim objSQLServer As SQLDMO.SQLServer
Set objSQLServer = New SQLDMO.SQLServer

'Fill in connection info
sServerName = "Server"
sUserID = "sa"
sPwd = ""

objSQLServer.Connect sServerName, sUserID, sPwd

This is the best I can do right now, but if you look through the object you should be able to find what you are looking for.  Let me know if you need more assistance.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8040409
Hi mvarghese,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept gencross's comment(s) as an answer.

mvarghese, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8095710
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question