SOS...SOS...SOS

C

Csharp?

Hello All

I am lost in Vbscript and can not find the proper support group. I hope
anyone of you who knows Vbscrip well will help me. I am trying to use
GetDataType function to extract recordsets data and return an array of
records by calling function GetDataType. My code is listed as follows. I
would like to substitute GetDataType1 with GetDataType, However, I got error
message. Basically, I want to know how to make a function return an array of
data. Please help.....

-- Function GetDataType()

Dim NumberOfDataType
Dim GetDataType1
const adOpenKeyset = 1
const adLockOptimistic = 3

dbpath = "C:\Base.mdb"
SQL2 = "SELECT Data_Types FROM CATALOG_DATA_TYPES;"
set conn=CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open dbpath
Set dst5 = CreateObject("ADODB.Recordset")
dst5.Open SQL2, conn, adOpenKeyset, adLockOptimistic
NumberOfDataType = dst5.RecordCount
redim GetDataType1(NumberOfDataType-1,0)
If Err.Number <> 0 Then
Response.Write("There was an error processing your request.<br>Please try
again.")
Exit Function
Else
If dst5.EOF and dst5.BOF Then
Response.Write("There are currently no records returned.")
Exit Function
Else
GetDataType1 = dst5.GetRows(9,0)
End If
End If
dst5.Close
conn.Close
Set dst5 = Nothing
set conn = Nothing
End Function


Csharp?
 
M

Michel Posseth [MCP]

maybe you could tell what your error is

As the getrows method is returning a variant array wich represents the
recordsets contents

as a variant in legacy VB , VBS , VBA is the substitute of our .Net Object
datatype ( it can hold everything you want ) you could just loop through it
an display the data


' --- Get the Variant-Array with Recorset Data
Dim VarExample As Variant
VarExample = RS.GetRows

Note :
The GetRows method is used to copy records from a Recordset object into a
variant that is a two-dimensional array. The variant array is automatically
dimensioned (sized) to fit the requested number of columns and rows. To
allow backwards compatibility with earlier versions of ADO, the columns are
placed in the first dimension of the array and the rows are placed in the
second dimension.

so your method should just return a variant







HTH

Michel
 
C

christery

Oh, didnt get how to CC, learned it now...

read on at

http://www.xefteri.com/articles/show.cfm?id=1

where the snippet (possibly) came from?

witch goes on with

'loop through rows
12 For numRowCounter = 0 To numRows
13 Response.Write("<tr>" & vbcrlf)
14 'for each column
15 For numColCounter = 0 to numCols
16 strthisfield = arrAllData(numColCounter, numRowCounter)
17 If IsNull(strthisfield) Then
18 strthisfield = "-null-"
19 End If
20 If Trim(strthisfield) = "" Then
21 strthisfield = " "
22 End If
23 Response.Write("<td valign=top>" & strthisfield & "</td>" &
vbcrlf)
24 Next
25 Response.Write("</tr>" & vbcrlf)
26 Next

//CY
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top