Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_database_setup thread: Open Access query


Message #1 by "Bart Beekhuizen" <bart@d...> on Mon, 5 Mar 2001 21:02:32 +0100
I'm having a problem with a query made in Access. This is the SQL:

----

SELECT TOP 5 Artiesten.ArtiestID, Artiesten.Artiestnaam,

ArtiestInternet.Reclame

FROM Artiesten INNER JOIN ArtiestInternet ON Artiesten.ArtiestID 

ArtiestInternet.ArtiestID

WHERE randomizer()=0 AND (((ArtiestInternet.Reclame)=True))

ORDER BY rnd(isnull(artiesten.artiestID) * 0 + 1);

-----

As you can see there's a function, randomizer, put in the query. This is the

code:

-----

Function Randomizer() As Integer

Static AlreadyDone As Integer

        If AlreadyDone = False Then Randomize: AlreadyDone = True

    Randomizer = 0

End Function

-----

What the query does is obvious: It selects all featured artists from table,

shows only 5 and does this random. So, is the thinking, on the website, we

always have featured artists. The performance is high because it opens a

query.

But it (off course) doesn't work. My questions are:

- how to connect this query on my ASP

	(This code doesn't work:

	strConn = "File name=" + Server.MapPath("connect.udl")

	Set db = Server.CreateObject("ADODB.Connection")

		db.Open strConn

	set Aanbevolen = Server.CreateObject("ADODB.Recordset")

		Aanbevolen.Open "SELECT * FROM InternetAanbevolen", db)

- if not possible: any other suggestions?



Regards,



Bart Beekhuizen



Message #2 by "mike s." <mikeseb@a...> on Wed, 7 Mar 2001 04:18:48
Within your function Randomizer() you have declared AlreadyDone as an 

integer, but your code checks it for the boolean value "false".  Maybe try 

declaring it as Boolean--unless I am misunderstanding what you are trying 

to do here.



Mike S.











> I'm having a problem with a query made in Access. This is the SQL:

> ----

> SELECT TOP 5 Artiesten.ArtiestID, Artiesten.Artiestnaam,

> ArtiestInternet.Reclame

> FROM Artiesten INNER JOIN ArtiestInternet ON Artiesten.ArtiestID 

> ArtiestInternet.ArtiestID

> WHERE randomizer()=0 AND (((ArtiestInternet.Reclame)=True))

> ORDER BY rnd(isnull(artiesten.artiestID) * 0 + 1);

> -----

> As you can see there's a function, randomizer, put in the query. This is 

the

> code:

> -----

> Function Randomizer() As Integer

> Static AlreadyDone As Integer

>         If AlreadyDone = False Then Randomize: AlreadyDone = True

>     Randomizer = 0

> End Function

> -----

> What the query does is obvious: It selects all featured artists from 

table,

> shows only 5 and does this random. So, is the thinking, on the website, 

we

> always have featured artists. The performance is high because it opens a

> query.

> But it (off course) doesn't work. My questions are:

> - how to connect this query on my ASP

> 	(This code doesn't work:

> 	strConn = "File name=" + Server.MapPath("connect.udl")

> 	Set db = Server.CreateObject("ADODB.Connection")

> 		db.Open strConn

> 	set Aanbevolen = Server.CreateObject("ADODB.Recordset")

> 		Aanbevolen.Open "SELECT * FROM InternetAanbevolen", db)

> - if not possible: any other suggestions?

> 

> Regards,

> 

> Bart Beekhuizen

> 

Message #3 by "Bart Beekhuizen" <bart@d...> on Wed, 7 Mar 2001 10:43:29 +0100
OK thanks for your thinking!

But the problem i'm experiencing is that I want to use this in an ASP page.

I wanto to open this query, already made in Access.

In Access this query works just fine: it opens only 5 records randomly. It

uses the function Randomizer well.

But with ASP the problem starts: I can't open the query because it has a

function in it that i can't use with ASP. I tcan't use the module in Access,

so I have to write a function in ASP that creates the same output as the

function in Access.

What i don't know if the SQL string in ASP is able to use a function within

the string.

What i need is code top open randomly 5 records from a table....... and it

seems difficult in ASP......



Regards,



Bart Beekhuizen



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

From: mike s. [mailto:mikeseb@a...]

Sent: woensdag 7 maart 2001 4:19

To: ASP Database Setup

Subject: [asp_database_setup] Re: Open Access query





Within your function Randomizer() you have declared AlreadyDone as an

integer, but your code checks it for the boolean value "false".  Maybe try

declaring it as Boolean--unless I am misunderstanding what you are trying

to do here.



Mike S.











> I'm having a problem with a query made in Access. This is the SQL:

> ----

> SELECT TOP 5 Artiesten.ArtiestID, Artiesten.Artiestnaam,

> ArtiestInternet.Reclame

> FROM Artiesten INNER JOIN ArtiestInternet ON Artiesten.ArtiestID 

> ArtiestInternet.ArtiestID

> WHERE randomizer()=0 AND (((ArtiestInternet.Reclame)=True))

> ORDER BY rnd(isnull(artiesten.artiestID) * 0 + 1);

> -----

> As you can see there's a function, randomizer, put in the query. This is

the

> code:

> -----

> Function Randomizer() As Integer

> Static AlreadyDone As Integer

>         If AlreadyDone = False Then Randomize: AlreadyDone = True

>     Randomizer = 0

> End Function

> -----

> What the query does is obvious: It selects all featured artists from

table,

> shows only 5 and does this random. So, is the thinking, on the website,

we

> always have featured artists. The performance is high because it opens a

> query.

> But it (off course) doesn't work. My questions are:

> - how to connect this query on my ASP

> 	(This code doesn't work:

> 	strConn = "File name=" + Server.MapPath("connect.udl")

> 	Set db = Server.CreateObject("ADODB.Connection")

> 		db.Open strConn

> 	set Aanbevolen = Server.CreateObject("ADODB.Recordset")

> 		Aanbevolen.Open "SELECT * FROM InternetAanbevolen", db)

> - if not possible: any other suggestions?

>

> Regards,

>

> Bart Beekhuizen

>


  Return to Index