|
-
Nov 5th, 1999, 01:36 AM
#1
Thread Starter
Hyperactive Member
I have a list box and I want to be able to automatically list all available tables in a certain database. I must use some form of code that allows for adding and deleting tables, and then updates the list accordingly. Please give some code, if you can. Thanks.
------------------
Ryan
[email protected]
ICQ# 47799046
-
Nov 5th, 1999, 02:39 AM
#2
Frenzied Member
What database are you planning in using?
-
Nov 5th, 1999, 02:58 AM
#3
Thread Starter
Hyperactive Member
I'm going to be using Sybase SQL Anywhere ver. 11 or 12. I believe the command structure is similar to Microsoft SQL, if that helps. Even if you just know how to do it for Microsoft SQL, I'll take that and try to make it work for Sybase. Thanks.
------------------
Ryan
[email protected]
ICQ# 47799046
-
Nov 5th, 1999, 05:40 AM
#4
Frenzied Member
For SQL Server the following will list all tables in the database:
"select name from sysobjects where type='U'"
SQL to delete a table
"drop tablename"
Adding a table is a bit more complex.
-
Nov 5th, 1999, 05:48 AM
#5
Thread Starter
Hyperactive Member
That looks like it just updates a list of tables that you already have displayed in a list box. But how do you create the list to begin with?
------------------
Ryan
[email protected]
ICQ# 47799046
-
Nov 5th, 1999, 12:19 PM
#6
Frenzied Member
Actually it's SQL to do 2 things, get all table entries and delete (drop) a table.
If you're not using a bound control, set up a routine that populates your listbox by stepping thru the get query (after using the clear method on the listbox). If you delete (or add) a table, just run that routine any time you do.
-
Nov 5th, 1999, 12:39 PM
#7
Guru
I did this using ado and the jet provider, it should work with SQL also
Dim cn As New ADODB.Connection
Dim rs As ADODB.Recordset
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database.mdb"
cn.Open
Set rs = cn.OpenSchema(adSchemaTables)
Do Until rs.EOF = True
MsgBox rs!TABLE_NAME
rs.MoveNext
Loop
Check out the ADO OpenSchema method, lots of good db info can be had
Tom
-
Nov 8th, 1999, 03:59 AM
#8
Thread Starter
Hyperactive Member
It looks like VB is having a problem with the Provider. Can you please explain what this is? Mayber I need to change it to work with Sybase SQL Server. Thanks
------------------
Ryan
[email protected]
ICQ# 47799046
-
Nov 8th, 1999, 09:19 AM
#9
Frenzied Member
It tells ADO what drivers to use to make the connection. You will have to change it to use your Sybase ADO drivers (you have them, right?). If you have VB6, you should be able to get the correct value (for Sybase) by using the dataview feature to create a new data environment connection (I cannot tell you what the Provider should be because I don't have Sybase DB's).
-
Nov 10th, 1999, 05:07 AM
#10
Thread Starter
Hyperactive Member
Ok, thanks
------------------
Ryan
[email protected]
ICQ# 47799046
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
|