Hi!!
tnx for the info that uve given me before with regards to databases..
i just want to know if there is a way to display a table's column name using vb6..
my database is in access 2003 format
tnx!
Printable View
Hi!!
tnx for the info that uve given me before with regards to databases..
i just want to know if there is a way to display a table's column name using vb6..
my database is in access 2003 format
tnx!
There are several ways, but like with most things to do with database related code, which one(s) are valid depend on which connection technology you are using - such as ADO code/ADO control/DAO control/...
Im using Ado Code..
One way is to open a recordset containing all columns, but no rows:
Another is to use OpenSchema. You can see an example (for Tables rather than fields) here.Code:Dim strSQL as String
Dim intField as Integer
Dim objRS as ADODB.Recordset
strSQL = "SELECT * FROM Table1 WHERE False"
objRS.Open strSQL, objCN, adOpenForwardOnly, adLockReadOnly, adCmdText
For intField = 0 To objRS.Fields.Count -1
MsgBox objRS.Fields(intField).Name
Next intField
objRS.Close
Set objRS = Nothing
Querying the data dictionary is helpful, if you're using Oracle.
sql Code:
SELECT column_name from dba_tab_columns where table_name = 'TABLE'