|
-
Jun 5th, 2000, 06:41 PM
#1
Thread Starter
Lively Member
How do i retrieve all the table names (except the schema ones) from sql server 7
I can't find an equivalent to cn.openschema
-
Jun 5th, 2000, 07:20 PM
#2
in SQL Server7 there is table called sysobject inside it all table names are there.... what all you required to do is fire select * query on it..and then apply some filter (that you can find out from values in diff columns..) which will give you list of only tables....
This will definetely work...
-
Jun 5th, 2000, 08:46 PM
#3
Thread Starter
Lively Member
Cheers!
BTW, there is only one column returned which is the object name ie table, key etc but no matter its easy from now on.
-
Jun 5th, 2000, 08:57 PM
#4
Thread Starter
Lively Member
Sorry Bavin,
select * from sysobjects only returns the object name
to get all the user tables
select id,name from sysobjects
where xtype='U'
Thanks once again.
-
Jun 5th, 2000, 09:12 PM
#5
Dear...
Select * From sysobjects
returns all the information in table sysobjects it is too much for normal programmer..(so it might be not useful to you...) ... what you replied it is also true...it will also work....but you mentioned that select * from sysobjects returns only table name it is not right....I am writing you just for info.
Bye
-
Jun 6th, 2000, 03:12 AM
#6
Frenzied Member
Run the stored procedure sp_help, without any parameters.
-
Jun 20th, 2000, 02:32 AM
#7
Addicted Member
What About Different Databases
I am creating a dianostic ASP, I already managed to create an ActiveX control that tells me every System DSN on the computer, plus the settings for each, and their drivers, how can I Get the table names for either Oracle, Oracle For Windows 7.3, Access, and SQL Server? once I Can get the table name, I Can take it a step further and allows the programers to view the Database setup by being able to see all the records, feilds, tables, DB settings, so forth.
-
Jun 20th, 2000, 02:04 PM
#8
Thread Starter
Lively Member
kb244,
Have some of my code! (this runs on sql 7)
This will populate a treeview with all user tables and fields!
You will have to supply your own connection string.
Private Sub PopulateNewQuery()
Dim rsNode As ADODB.Recordset
Dim rsChild As ADODB.Recordset
Dim nodTemp As Node
Dim strSQL As String
Dim strNodeName As String
Dim strKey As String
Dim strFld As String
Me.Refresh
'has the treeview already been populated
If tvwDB.Nodes.Count > 0 Then Exit Sub
'update ui
Screen.MousePointer = vbHourglass
sbrStatus.Panels("Info") = "Please wait, retrieving Database structure."
'get all the user tables
Set rsNode = New ADODB.Recordset
rsNode.CursorLocation = adUseClient
rsNode.Open "select name from sysobjects where xtype='U' order by name", m_strConn
'setup progressbar
prgRecordCounts.TotalValue = rsNode.RecordCount
prgRecordCounts.Value = rsNode.AbsolutePosition
'populate treeview
Set rsChild = New ADODB.Recordset
While Not rsNode.EOF
strNodeName = rsNode!Name
Set nodTemp = tvwDB.Nodes.Add(, , strNodeName, strNodeName)
'get all the table details
strSQL = "exec sp_columns '" & strNodeName & "'"
rsChild.Open strSQL, m_strConn
'get each field name and add it to the node as a branch
While Not rsChild.EOF
strFld = rsChild!column_name
strKey = strNodeName & "." & strFld
Set nodTemp = tvwDB.Nodes.Add(strNodeName, tvwChild, strKey, strFld)
rsChild.MoveNext
Wend
rsChild.Close
'update progressbar
prgRecordCounts.Text = "Loading Database structure."
prgRecordCounts.Value = rsNode.AbsolutePosition
rsNode.MoveNext
Wend
'update ui
prgRecordCounts.Text = ""
prgRecordCounts.ShowStatus = False
prgRecordCounts.TextAfterProgress = "Database structure loaded."
sbrStatus.Panels("Info") = "Database structure retrieval complete."
Screen.MousePointer = vbDefault
End Sub
After I'd completed this I found out that ADO has
rs.openschema( providertype) and other options. This may/not work for providers such as oracle.
 VB6 Enterprise sp5, SQL Server2000 
-
Jun 20th, 2000, 06:22 PM
#9
Addicted Member
Thanks
thanks for you info, I will use it to my advantage, however I dont think you can create a treview on an ActiveServer Page unless you do something clientside, might try to simulate a treeview with the ASP if i know how (like on click, then make the ASP expand the view when it reloads)
-
Jun 20th, 2000, 09:07 PM
#10
Thread Starter
Lively Member

I just copy/paste a wedge of code for you.
The treeview and progressbar are irrelevant for your needs but I thought you might like to plonk a treeview (name tvwDB) on a form in a new exe and just run the code.
rgds
frank
 VB6 Enterprise sp5, SQL Server2000 
-
Jun 20th, 2000, 09:10 PM
#11
Addicted Member
Although the table retreiving works fine for SQL, I still cannot figure out how to get the list of tables from an Access DB, or Oracle, those are the other few DSN on our webserver that cant use the same technique for getting all the table names. (hopefully though getting all the Field name works just the same, which I assume it does)
-
Jun 20th, 2000, 09:27 PM
#12
Addicted Member
this is what I am using to grab the tables.
If Trim(Request.Form("Driver")) = "SQL Server" then
Conn.Open Request.Form("Path"), "sa", "***"
RS.Open "select * from sysobjects where type='U'", Conn, adOpenStatic
else
Conn.Open Request.Form("Path"), "sa", ""
RS.Open "select * from MSysObjects where type=1", conn, adOpenStatic
end if
The connection and recordset for the SQL works fine, however for the access databases, connection goes fine, but the recordset crashes stating that there is no read permision for the MSysObjects, says this about all access databases that I Try to get the table names of.
-
Jun 20th, 2000, 09:28 PM
#13
Thread Starter
Lively Member
-
Jun 20th, 2000, 09:31 PM
#14
Thread Starter
Lively Member
-
Jun 20th, 2000, 09:35 PM
#15
Addicted Member
Just so you know I am not using Visual basic, so theres no such thing as Form_Load , and events where I'm working, I'm using Vbscript serverside on an ActiveServer page. still able to use alot of the functionality on the serverside as in Visual basic, but there are some difference, like it's all procedural, from top to bottom, program finished. thanks for your response, I'll give the openschema a try.
-
Jun 20th, 2000, 09:35 PM
#16
Thread Starter
Lively Member
kb244,
sorry to be pedantic but you're obviously going to have to create the conn' string yourself!
rgds
frank
 VB6 Enterprise sp5, SQL Server2000 
-
Jun 20th, 2000, 09:38 PM
#17
Addicted Member
Seems that it says it is not supported by the provider, I'll try other schemas and see if its just the constants that arnt supported or the whole shema thing.
-
Jun 20th, 2000, 09:39 PM
#18
Thread Starter
Lively Member
Appreciate your lack of VB but the proc' signature is only there because I had to put the code somewhere.
Shouldn't this be in a DLL anyway?
frank 
 VB6 Enterprise sp5, SQL Server2000 
-
Jun 20th, 2000, 09:45 PM
#19
Addicted Member
I've already written a ActiveX dll, to get the list of DSN in the ODBC, along with their settings, also included in the dll, is the ability to get the list of all OCX/exe/Dll in a path, and their version information, as well as a bunch of other informatino about the system, which is presented through an ASP, you see I am writing a Dianostic site, it'll allow us to to check on the customer's webserver, if they are having problems, through the site we'll be able to see their reasoruces, all their DSN, version informations of any activeX files, etc etc. makes it alot easier than calling them up and asking them ourselves, still need to figure out how to dyanically show the content of each database ( succeeded in the SQL part, not in the Access/Oracle) kind of an online DB browser, already wrote an Online ActiveX version browser, just need to also figure out how to get infomation about the web services running, as you can see this is just a small part of a larger project (also the ActiveX dll is only 40Kilobytes, I only used windows API in it)
-
Jun 20th, 2000, 09:47 PM
#20
Thread Starter
Lively Member
kb244,
I was just walking out the door when your post got to me!
Sorry, my fault. vbconstants is where you put the constant eg
adschemacolumns
adschemaasserts
adschemacatalogs
and so on.
As VB has early binding and intellisense all the possible constants are staring me in the face, I've only used Interdev6 and from what I remember those options are missing/lacking.
Microsoft might have a list of constants (ado is referred to as mdac!)
rgds
frank

 VB6 Enterprise sp5, SQL Server2000 
-
Jun 20th, 2000, 09:48 PM
#21
Addicted Member
Post concerning conn string
Um I already have a connection string, if you notice some of the post above, I stated, connection goes perfectly, it's a DSN, so no need to tell it provider and what not, only reason I pass the provider over, is so I can do an IF then, and open the recordset according to the type of DB it is.
-
Jun 20th, 2000, 09:53 PM
#22
Addicted Member
Post Concerning Constants
I'm using Visual InterDev 6, and when I use OpenSchema, I see all those constants in a pulldown list including one for returning tables, but as I mentioned before it said my provider didnt support them(access DB), the ADODB object supports almost all of anything in VB since it is at least ADO 2.0. anyways thanks for your help(and those who helped you) and possibly talk to you tommarrow (scoot scoo out the door)
-
Jun 20th, 2000, 10:26 PM
#23
Thread Starter
Lively Member
-
Jun 20th, 2000, 11:14 PM
#24
Addicted Member
Yea it worked for Access and SQL also , if i use the # 20, which is the value of the constant, apparently they dont sometimes put in the right value or no value at all for the constant, right now just trying to figure out how to make the TABLE_NAME field the first field of a record, and sort it by TABLE types, and not system Tables, etc. I'll figure it out eventually, I was told you can do the same thing with Oracle if you get it right.
-
Jun 21st, 2000, 02:47 PM
#25
Thread Starter
Lively Member
-
Jun 21st, 2000, 07:15 PM
#26
Addicted Member
for sql i just use this
"Select name, refdata, crdate from sysobject where type = 'U'"
for access I use
set rs = conn.openSchema(20, Array(empty, empty, empty, "Table")
(just need to create a new recordset and throw the fields I want into it, in the order that I want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|