Link to home
Start Free TrialLog in
Avatar of raghx_2000
raghx_2000

asked on

About Columns

Hi !

I want some function which is equivalent to SQLNumResultCols( ) in VB, since iam using ADODB.
Also i want to count the Column Length of a table, how can i do ?

Can someone help me with a piece of code please.... would be much helpful..

Regards
Avatar of bwh1te
bwh1te

You could put your adodb recordset results in to variant array which would give you the ability to count the rows. The method is getRows as shown below. If you stuffed this into a function then for each recordset you return you can count through the array dimension and get you column count / row count etc.

Dim objRs As New ADODB.Recordset
Dim objCmd As New ADODB.Command
Dim objConn As New ADODB.Connection
objConn.Open strDbConnectionString
objCmd.CommandText = strSQL
objCmd.CommandType = adCmdText
Set oCmd.ActiveConnection = objConn
ObjRs.Open oCmd


MethodName = objRs.GetRows
dim i as integer
for i = 0 to uBound(MethodName)
  'do what you want with your array data in here such as count the number of columns
next

objRs.Close
objConn.Close
Set objRs= Nothing
Set objCmd= Nothing
Set objConn= Nothing


 

objRs.Fields.count is also preferable in this way.
Avatar of raghx_2000

ASKER

I think some mistake here !

I dont want to count columns, i want to count the length of each column in a table.
Ex: if i have a columns like this in table XXX then
Column name  Datatype Lenght
Name             VArchar  12
Id                   Numeric 6
Then i must count the length....
How .... ?
any code sample will do....
ASKER CERTIFIED SOLUTION
Avatar of johanmulder
johanmulder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial