Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

vb oracle ado?

Thread Tools
 
Search this Thread
 
Old 04 January 2002, 02:57 PM
  #1  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

how do i do the sql equivalent of 'desc employee_table;' in an ado command/recordset (to return the table definition into VB)?

sorry about the geeky question

Old 04 January 2002, 03:50 PM
  #2  
BigGT3Fan
Scooby Regular
 
BigGT3Fan's Avatar
 
Join Date: Jul 2001
Posts: 464
Likes: 0
Received 0 Likes on 0 Posts
Post


Fosters,

I don't know how to to directly send a DESC command to the DB and get back the results as a text string, sounds like that would not be possible.

You need to use the ADOX library, which supports extended operations & DDL through a set of ADO objects.

This will allow you to get back an object model containing all the tables in your schema, all their columns, datatypes etc.

You can then traverse this object structure to read the schema definitions generically.

HTH,




Alex
Old 04 January 2002, 04:01 PM
  #3  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

I cheated!

Function GetDescForTable() As String()
Dim TD() As String
Dim RS As New ADODB.Recordset
Dim sSQL As String
sSQL = "select column_name, data_type " & _
"from dba_tab_columns where owner = 'P11D' " & _
"and table_name = '" & UCase(Form1.cmbTables.Text) & "'"
RS.Open sSQL, sCN, adOpenStatic, adLockReadOnly
ReDim TD(2, 0)
While Not RS.EOF
ReDim Preserve TD(2, UBound(TD, 2) + 1)
TD(0, UBound(TD, 2) - 1) = RS!column_name
TD(1, UBound(TD, 2) - 1) = RS!data_type
RS.MoveNext
Wend
RS.Close
GetDescForTable = TD
End Function
Old 04 January 2002, 05:37 PM
  #4  
DazV
Scooby Regular
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

If you're using ASP, just whack it into the SQL string...

Dim myrecordset
Set myrecordset=server.createobject("ADODB.Recordset")
sqltext = "SELECT forename, surname FROM customers ORDER BY surname DESC;"
myrecordset.Open sqltext, "DSN=whatever"
etc...

Old 04 January 2002, 06:33 PM
  #5  
BigGT3Fan
Scooby Regular
 
BigGT3Fan's Avatar
 
Join Date: Jul 2001
Posts: 464
Likes: 0
Received 0 Likes on 0 Posts
Post

Fosters - yeah, that will work. I guess ADOX is generic and gives you DDL and schema info for whatever db you are using, whereas your method is Oracle specific.




Alex
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
darlodge
Computer & Technology Related
10
18 October 2003 04:08 PM
Kevin Mc
Computer & Technology Related
4
17 September 2003 01:21 PM
Mickle
Computer & Technology Related
2
14 May 2003 05:19 PM
stan
Non Scooby Related
5
20 September 2000 02:07 PM



Quick Reply: vb oracle ado?



All times are GMT +1. The time now is 07:59 AM.