Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: arrays with DB's


Message #1 by "Brent Williams" <brent@a...> on Mon, 8 May 2000 08:53:26 -0230
Im tring to list a database in a array, I have the following code but it

doesn't seem to display any records, I was wondering if anyone could tell me

what im doing wrong!



thanks,  brent

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



Dim X

Dim objRec



Set objRec = Server.CreateObject("ADODB.Recordset")



objRec.Open "Products", strConnect, adOpenKeyset, _

                                                          adLockReadOnly,

adCmdTable



 X = 1

 X = X + 1

 Function GetItemParameters(iItemID)

 Dim aParameters

 Select Case iItemID

   Case X

     While Not objRec.EOF

          aParameters = Array(objRec("description"), objRec("price"))

         objRec.MoveNext

     Wend

 End Select

 GetItemParameters = aParameters

 End Function



objRec.Close

Set objRec = Nothing



Message #2 by "Ruud Voigt" <RuudVoigt@w...> on Mon, 8 May 2000 14:47:03 +0200
It looks to me as if you are redefining the array variable (aParameters)

everytime you go through your while not objRec.EOF loop.

What are you looking for?

Do you want an array in which each record contains

another array containing the 2 DB Values?

Or an array which contains all these in one 'colom'?





-----Original Message-----

From: Brent Williams 

Sent: maandag 8 mei 2000 13:23

To: ASP Databases

Subject: [asp_databases] arrays with DB's





Im tring to list a database in a array, I have the following code but it

doesn't seem to display any records, I was wondering if anyone could tell me

what im doing wrong!



thanks,  brent

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



Dim X

Dim objRec



Set objRec = Server.CreateObject("ADODB.Recordset")



objRec.Open "Products", strConnect, adOpenKeyset, _

                                                          adLockReadOnly,

adCmdTable



 X = 1

 X = X + 1

 Function GetItemParameters(iItemID)

 Dim aParameters

 Select Case iItemID

   Case X

     While Not objRec.EOF

          aParameters = Array(objRec("description"), objRec("price"))

         objRec.MoveNext

     Wend

 End Select

 GetItemParameters = aParameters

 End Function



objRec.Close

Set objRec = Nothing





---

You are currently subscribed to asp_databases






Message #3 by "Shawn Steward" <ssteward@a...> on Mon, 8 May 2000 15:14:10
If you just want to store the contents of your table in a single array, you 

should be able to use the following code:





Dim x

Dim objRec

 

Set objRec = Server.CreateObject("ADODB.Recordset")

 

objRec.Open "Products", strConnect, adOpenKeyset, _ 

adLockReadOnly, adCmdTable



x = objRec.RecordCount - 1  '0-based record count



Function GetItemParameters(iItemID)

  Dim aParameters(1,x)



       For i = 0 to x

          aParameters(0,i) = objRec("description")

          aParameters(1,i) = objRec("price")

       Next



  GetItemParameters = aParameters

End Function

 

 objRec.Close

 Set objRec = Nothing





Good Luck!



Shawn





On 05/08/00, "Brent Williams" wrote:

> Im tring to list a database in a array, I have the following code but it

> doesn't seem to display any records, I was wondering if anyone could tell me

> what im doing wrong!

> 

> thanks,  brent

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

> 

> Dim X

> Dim objRec

> 

> Set objRec = Server.CreateObject("ADODB.Recordset")

> 

> objRec.Open "Products", strConnect, adOpenKeyset, _

>                                                           adLockReadOnly,

> adCmdTable

> 

>  X = 1

>  X = X + 1

>  Function GetItemParameters(iItemID)

>  Dim aParameters

>  Select Case iItemID

>    Case X

>      While Not objRec.EOF

>           aParameters = Array(objRec("description"), objRec("price"))

>          objRec.MoveNext

>      Wend

>  End Select

>  GetItemParameters = aParameters

>  End Function

> 

> objRec.Close

> Set objRec = Nothing

Message #4 by Tristian O'brien <obrient@m...> on Mon, 8 May 2000 16:22:55 +0100
why not try





Dim x

Dim objRec

 

Set objRec = Server.CreateObject("ADODB.Recordset")



	'puts the rs stright into the variant

	x = objRec.getrows



objRec.Close

Set objRec = Nothing















-----Original Message-----

From: Shawn Steward 

Sent: 08 May 2000 16:14

To: ASP Databases

Subject: [asp_databases] Re: arrays with DB's





If you just want to store the contents of your table in a single array, you 

should be able to use the following code:





Dim x

Dim objRec

 

Set objRec = Server.CreateObject("ADODB.Recordset")

 

objRec.Open "Products", strConnect, adOpenKeyset, _ 

adLockReadOnly, adCmdTable



x = objRec.RecordCount - 1  '0-based record count



Function GetItemParameters(iItemID)

  Dim aParameters(1,x)



       For i = 0 to x

          aParameters(0,i) = objRec("description")

          aParameters(1,i) = objRec("price")

       Next



  GetItemParameters = aParameters

End Function

 

 objRec.Close

 Set objRec = Nothing





Good Luck!



Shawn





On 05/08/00, "Brent Williams" wrote:

> Im tring to list a database in a array, I have the following code but it

> doesn't seem to display any records, I was wondering if anyone could tell

me

> what im doing wrong!

> 

> thanks,  brent

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

> 

> Dim X

> Dim objRec

> 

> Set objRec = Server.CreateObject("ADODB.Recordset")

> 

> objRec.Open "Products", strConnect, adOpenKeyset, _

>                                                           adLockReadOnly,

> adCmdTable

> 

>  X = 1

>  X = X + 1

>  Function GetItemParameters(iItemID)

>  Dim aParameters

>  Select Case iItemID

>    Case X

>      While Not objRec.EOF

>           aParameters = Array(objRec("description"), objRec("price"))

>          objRec.MoveNext

>      Wend

>  End Select

>  GetItemParameters = aParameters

>  End Function

> 

> objRec.Close

> Set objRec = Nothing



---

You are currently subscribed to asp_databases 




Message #5 by Mark Everest <Mark.Everest@t...> on Mon, 8 May 2000 16:08:16 +0100
If you are using ADO you can use the GetRows method on the recordset - this

returns a multi dimentional array of field values.



Check out "GetRows Method" in MSDN.





-----Original Message-----

From: Shawn Steward 

Sent: 08 May 2000 16:14

To: ASP Databases

Subject: [asp_databases] Re: arrays with DB's





If you just want to store the contents of your table in a single array, you 

should be able to use the following code:





Dim x

Dim objRec

 

Set objRec = Server.CreateObject("ADODB.Recordset")

 

objRec.Open "Products", strConnect, adOpenKeyset, _ 

adLockReadOnly, adCmdTable



x = objRec.RecordCount - 1  '0-based record count



Function GetItemParameters(iItemID)

  Dim aParameters(1,x)



       For i = 0 to x

          aParameters(0,i) = objRec("description")

          aParameters(1,i) = objRec("price")

       Next



  GetItemParameters = aParameters

End Function

 

 objRec.Close

 Set objRec = Nothing





Good Luck!



Shawn





On 05/08/00, "Brent Williams" wrote:

> Im tring to list a database in a array, I have the following code but it

> doesn't seem to display any records, I was wondering if anyone could tell

me

> what im doing wrong!

> 

> thanks,  brent

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

> 

> Dim X

> Dim objRec

> 

> Set objRec = Server.CreateObject("ADODB.Recordset")

> 

> objRec.Open "Products", strConnect, adOpenKeyset, _

>                                                           adLockReadOnly,

> adCmdTable

> 

>  X = 1

>  X = X + 1

>  Function GetItemParameters(iItemID)

>  Dim aParameters

>  Select Case iItemID

>    Case X

>      While Not objRec.EOF

>           aParameters = Array(objRec("description"), objRec("price"))

>          objRec.MoveNext

>      Wend

>  End Select

>  GetItemParameters = aParameters

>  End Function

> 

> objRec.Close

> Set objRec = Nothing



Message #6 by "Brent Williams" <brent@a...> on Tue, 9 May 2000 00:07:49 -0230
Wow thanks thats a huge help



brent

----- Original Message -----

From: "Shawn Steward" <ssteward@a...>

To: "ASP Databases" <asp_databases@p...>

Sent: Monday, May 08, 2000 3:14 PM

Subject: [asp_databases] Re: arrays with DB's





> If you just want to store the contents of your table in a single array,

you

> should be able to use the following code:

>

>

> Dim x

> Dim objRec

>

> Set objRec = Server.CreateObject("ADODB.Recordset")

>

> objRec.Open "Products", strConnect, adOpenKeyset, _

> adLockReadOnly, adCmdTable

>

> x = objRec.RecordCount - 1  '0-based record count

>

> Function GetItemParameters(iItemID)

>   Dim aParameters(1,x)

>

>        For i = 0 to x

>           aParameters(0,i) = objRec("description")

>           aParameters(1,i) = objRec("price")

>        Next

>

>   GetItemParameters = aParameters

> End Function

>

>  objRec.Close

>  Set objRec = Nothing

>

>

> Good Luck!

>

> Shawn

>

>

> On 05/08/00, "Brent Williams" wrote:

> > Im tring to list a database in a array, I have the following code but it

> > doesn't seem to display any records, I was wondering if anyone could

tell me

> > what im doing wrong!

> >

> > thanks,  brent

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

> >

> > Dim X

> > Dim objRec

> >

> > Set objRec = Server.CreateObject("ADODB.Recordset")

> >

> > objRec.Open "Products", strConnect, adOpenKeyset, _

> >

adLockReadOnly,

> > adCmdTable

> >

> >  X = 1

> >  X = X + 1

> >  Function GetItemParameters(iItemID)

> >  Dim aParameters

> >  Select Case iItemID

> >    Case X

> >      While Not objRec.EOF

> >           aParameters = Array(objRec("description"), objRec("price"))

> >          objRec.MoveNext

> >      Wend

> >  End Select

> >  GetItemParameters = aParameters

> >  End Function

> >

> > objRec.Close

> > Set objRec = Nothing

>

> ---

> You are currently subscribed to asp_databases


$subst('Email.Unsub')

>



Message #7 by "Brent Williams" <brent@a...> on Tue, 9 May 2000 00:21:09 -0230
What Im tring to do is us a database to display information into an array

for a online quote that im tring to figure out, i have most of it working

perfect but i can seem to get the database to display the information i

want, all thats in the database is a ID, Description, and Price thats all,

and the table only displays the description and price to the user, i have an

array in asp now that holds the info but i wanted a database to do it for

me, im totally new to both ASP and databases, I've been learn bits and

pieces everyday for about two months now and it's really fun to play with!

but when i run into problems like this where i don't know what to do it

becomes a pain really.



if you want to see what im doing goto

http://25warp69.newtel.com/quote/quote.asp that will run the quote, but

thats using the  asp array built into the asp file its self.



if you could help me out that would be awesome



thanks,  brent





----- Original Message -----

From: "Ruud Voigt"

To: "ASP Databases" <asp_databases@p...>

Sent: Monday, May 08, 2000 10:17 AM

Subject: [asp_databases] RE: arrays with DB's





> It looks to me as if you are redefining the array variable (aParameters)

> everytime you go through your while not objRec.EOF loop.

> What are you looking for?

> Do you want an array in which each record contains

> another array containing the 2 DB Values?

> Or an array which contains all these in one 'colom'?

>

>

> -----Original Message-----

> From: Brent Williams

> Sent: maandag 8 mei 2000 13:23

> To: ASP Databases

> Subject: [asp_databases] arrays with DB's

>

>

> Im tring to list a database in a array, I have the following code but it

> doesn't seem to display any records, I was wondering if anyone could tell

me

> what im doing wrong!

>

> thanks,  brent

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

>

> Dim X

> Dim objRec

>

> Set objRec = Server.CreateObject("ADODB.Recordset")

>

> objRec.Open "Products", strConnect, adOpenKeyset, _

>                                                           adLockReadOnly,

> adCmdTable

>

>  X = 1

>  X = X + 1

>  Function GetItemParameters(iItemID)

>  Dim aParameters

>  Select Case iItemID

>    Case X

>      While Not objRec.EOF

>           aParameters = Array(objRec("description"), objRec("price"))

>          objRec.MoveNext

>      Wend

>  End Select

>  GetItemParameters = aParameters

>  End Function

>

> objRec.Close

> Set objRec = Nothing


  Return to Index