[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Get Info from certain database from SQL Server.

Posted on 2001-08-08
13
Medium Priority
?
226 Views
Last Modified: 2008-02-01
Is there any VB application with source code that allow
user to login into SQL Server, then pull all the table
name(include all the fields for each table), stored procedures that are associated with the login user ?
0
Comment
Question by:superCombo2001
  • 5
  • 5
  • 3
13 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6363854
You are asking for a lot there, lets take it apart a little:

There are three ways (at least) to get the columns/tables from a database:

1) ADO using Connection.OpenSchema
2) ADOX using catalog and tables/columns collections
3) SQL-DMO

Of the three, 1) is the easiest and quickest to implement and 3) is the most powerful.

The SQL-DMO object library allows effectively the same level of control and access that SQL enterprise manager does. This means that not only can you natively access the tables and columns, you can also access the stored procedures/logins/users etc in the database.

If you wish to go down one of these routes, let me know and I will see if I can give you some appropriate examples.
0
 
LVL 11

Expert Comment

by:Nitin Sontakke
ID: 6363855
I don't know any readymade code. But it is fairly easy to write your own using "Microsoft SQLDMO Object Library".

0
 

Author Comment

by:superCombo2001
ID: 6364355
I will want to use SQL-DMO.
I know I asked a lot, but I will increase points soon.
Thanks !
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 43

Accepted Solution

by:
TimCottee earned 280 total points
ID: 6364473
Here is a starter on SQL-DMO, add a reference to it in the project;

Private Sub Command2_Click()
    Dim srvSQL As SQLDMO.SQLServer
    Set srvSQL = New SQLDMO.SQLServer
    Dim tblTable As Table
    Dim clmColumn As Column
    Dim stpProcedure As StoredProcedure
    Dim upmUserPermissions As SQLObjectList
    srvSQL.Name = "MySQLServerName"
    srvSQL.Connect
    For Each tblTable In srvSQL.Databases("QCDataCollect").Tables
        For Each clmColumn In tblTable.Columns
            strMessage = ""
            strMessage = strMessage & "Allow Nulls = " & clmColumn.AllowNulls & vbLf
            strMessage = strMessage & "AnsiPaddingStatus = " & clmColumn.AnsiPaddingStatus & vbLf
            strMessage = strMessage & "ComputedText = " & clmColumn.ComputedText & vbLf
            strMessage = strMessage & "Datatype = " & clmColumn.Datatype & vbLf
            strMessage = strMessage & "Default = " & clmColumn.Default & vbLf
            strMessage = strMessage & "DefaultOwner = " & clmColumn.DefaultOwner & vbLf
            strMessage = strMessage & "FullTextIndex = " & clmColumn.FullTextIndex & vbLf
            strMessage = strMessage & "I = " & clmColumn.ID & vbLf
            strMessage = strMessage & "Identity = " & clmColumn.Identity & vbLf
            strMessage = strMessage & "IdentityIncrement = " & clmColumn.IdentityIncrement & vbLf
            strMessage = strMessage & "IdentitySeed = " & clmColumn.IdentitySeed & vbLf
            strMessage = strMessage & "InPrimaryKey = " & clmColumn.InPrimaryKey & vbLf
            strMessage = strMessage & "IsComputed = " & clmColumn.IsComputed & vbLf
            strMessage = strMessage & "IsRowGuidCol = " & clmColumn.IsRowGuidCol & vbLf
            strMessage = strMessage & "Length = " & clmColumn.Length & vbLf
            strMessage = strMessage & "Name = " & clmColumn.Name & vbLf
            strMessage = strMessage & "NotForRepl = " & clmColumn.NotForRepl & vbLf
            strMessage = strMessage & "NumericPrecision = " & clmColumn.NumericPrecision & vbLf
            strMessage = strMessage & "NumericScale = " & clmColumn.NumericScale & vbLf
            strMessage = strMessage & "PhysicalDatatype = " & clmColumn.PhysicalDatatype & vbLf
            strMessage = strMessage & "TypeOf = " & clmColumn.TypeOf & vbLf
            strMessage = strMessage & "UserData = " & clmColumn.UserData
            MsgBox strMessage
        Next
    Next
    srvSQL.Disconnect
    Set srvSQL = Nothing
End Sub
0
 

Author Comment

by:superCombo2001
ID: 6365062
Where to find SQL DMO ? What dir ?
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6365070
If you have SQL server 7 Client installed on your development machine, you should be able to go to the project menu in VB and choose references, Microsoft SQLDMO Object Library should be there in the list, simply check it and ok. If you don't have it but have SQLOLE instead, this may work but was designed for SQL 6.5 rather than 7 and may not have all the features implemented in the same way.
0
 

Author Comment

by:superCombo2001
ID: 6365082
I can see MS SQLDMO library in the reference box.
When I checked it, and hit ok, the vb told me that
the library is missing.

What is the full name of that library ?
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6365097
Ok, on my install it is in c:\mssql7\binn\resources\1033\sqldmo.rll
0
 
LVL 11

Expert Comment

by:Nitin Sontakke
ID: 6365105
On my machine:
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqldmo.dll
0
 
LVL 11

Expert Comment

by:Nitin Sontakke
ID: 6365109
Mine is SQL Server 2K.
0
 

Author Comment

by:superCombo2001
ID: 6365147
Give me sometime to evaluate the code.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6367080
No problem, if you have any more questions just ask and I will do my best to help.
0
 

Author Comment

by:superCombo2001
ID: 6388696
TimCottee,

Where can I get books or URL resources for more implementation detail on SQLDMO ?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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
Course of the Month18 days, 10 hours left to enroll

834 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