|
 |
asp_databases thread: Connect Function Problem
Message #1 by "Andi Gladwin" <andi@a...> on Wed, 20 Sep 2000 14:05:06 +0100
|
|
Hi!
Can anyone see any problems in this code? It is supposed to be a function
to open a database, so that queeries can be made using SQL, but it never
seems to save anything to the database, or open it for that matter!
Here's the code:
Function DBOpen()
set DBOpen = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("../../db/members.mdb")
OpenDB.open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & DBPath
& ";"
End Function
Function runquery(SQL)
set database = DBOpen()
set runquery = dbase.execute(SQL)
set database = Nothing
End Function
And I also use the following to run the query:
SQL = "SELECT * from forums"
Set DBData = runquery(SQL)
But... nothing seems to be happening; no errors, no data being opened or
saved but the page loads as normal (without the database content).
Anyone see my mistake?
Thanks
Andi
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 21 Sep 2000 13:22:00 +1000
|
|
> set runquery = dbase.execute(SQL)
Shouldn't this be:
Set runQuery = database.execute(SQL)
?
Cheers
Ken
Message #3 by "Bhanu" <cbpr2@y...> on Thu, 21 Sep 2000 10:07:04 +0530
|
|
I think you mispelt connection object in the beginning if i am not wrong.
you have used DBOpen for setting the connection object
set DBOpen = Server.CreateObject("ADODB.Connection")
here you are using OpenDB for opening.
OpenDB.open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & DBPath
& ";"
End Function
----- Original Message -----
From: Andi Gladwin <andi@a...>
To: ASP Databases <asp_databases@p...>
Sent: Wednesday, September 20, 2000 6:35 PM
Subject: [asp_databases] Connect Function Problem
> Hi!
>
> Can anyone see any problems in this code? It is supposed to be a function
> to open a database, so that queeries can be made using SQL, but it never
> seems to save anything to the database, or open it for that matter!
>
> Here's the code:
>
> Function DBOpen()
> set DBOpen = Server.CreateObject("ADODB.Connection")
> DBPath = Server.MapPath("../../db/members.mdb")
> OpenDB.open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & DBPath
> & ";"
> End Function
>
> Function runquery(SQL)
> set database = DBOpen()
> set runquery = dbase.execute(SQL)
> set database = Nothing
> End Function
>
> And I also use the following to run the query:
>
> SQL = "SELECT * from forums"
> Set DBData = runquery(SQL)
>
> But... nothing seems to be happening; no errors, no data being opened or
> saved but the page loads as normal (without the database content).
>
> Anyone see my mistake?
>
> Thanks
>
> Andi
>
>
|
|
 |