getting db field name 
Author Message
 getting db field name

Hello.

I am trying to get the fields name from recordset.

here is my vb code

-------
dim rs as new adodb.recordset
dim cn as new adodb.connection

cn.open "dsn=whatever;uid=user;pwd=password"
set rs = cn.execute("select * from table1")

msgbox ????????? <------------------------------------I want to display
first and last field names from table1

-----------------------------

anyone know how to do this???

it doesn't have to be using ado.

Sample code will help, thanx in advance



Sat, 07 May 2005 07:37:18 GMT  
 getting db field name
Hi BK,
This is a simple thing to do. You can use something like
this code snippet to do what you want. You don't have to
use the local variable if you know the number of fields
in your table, just remember to subtract one from the
total to compensate for the zero based fields collection.

Dim i As Integer
i = rs.Fields.Count - 1

MsgBox "The first field name is " & rs.Fields(0).Name &
vbCrLf & _
                "The Last Field name is " & rs.Fields
(i).Name, , "Test"

HTH
Ed Voss
MCP

Quote:
>-----Original Message-----
>Hello.

>I am trying to get the fields name from recordset.

>here is my vb code

>-------
>dim rs as new adodb.recordset
>dim cn as new adodb.connection

>cn.open "dsn=whatever;uid=user;pwd=password"
>set rs = cn.execute("select * from table1")

>msgbox ????????? <------------------------------------I
want to display
>first and last field names from table1

>-----------------------------

>anyone know how to do this???

>it doesn't have to be using ado.

>Sample code will help, thanx in advance

>.



Sat, 07 May 2005 09:04:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting names from db with id's from xml (dataset join question)

2. Getting table names from an SQL-Server DB

3. Getting table names from a db

4. Getting Fields from a Text ODBC db

5. How do I use contents of variable as field name(db!rst!variable)

6. Get fields name from DB ! Help

7. using csv file headings for access db field names in VB

8. CODE: Reading DB Field Names

9. purging names of fields in access db

10. get list of field names in access db table

11. Getting field from its name

12. mail to multiple ppl with each one getting only his name in the To field

 

 
Powered by phpBB® Forum Software