 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 22nd, 2007, 12:44 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi...this website has only connection strings for access 2007, but I only have Access 2003. I don't think they are compatible. Do you know if this is the case?
|
|

February 22nd, 2007, 12:58 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, I'm in the process of setting up the JET driver. But, this leads me to 2 more stupid questions (sorry, I'm a novice!)
1.) I have to give a pathway for the database. When I put this DB on a server somewhere, I'm not sure what the path should be and how specific it needs to be. For example, can I just put the directory that the DB is in on the SERVER or do I need to put the server's IP address or anything on there?
2.) Do I need to include the code for the JET driver in every .asp file that I write that includes a database connection/interaction? Or does it connect once, and then it's opened and saved in the cache somewhere? I'm not sure if this question will even make any sense to you.
thanks again
|
|

February 22nd, 2007, 01:24 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
No you have to open it everytime you want to use it.
To supply the path to the database you would use Server.MapPath(<relative path to database from current directory>)
So if your database is in a folder called dbase in the root directory and you are opening a connect to the database on a page that is in your root directory your statement would be
Server.MapPath("./dbase/file.mdb")
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
|
|

February 22nd, 2007, 01:29 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
just out of shear curiousity...
what does the "./" in this line: Server.MapPath("./dbase/file.mdb")
tell the server?
thanks for humoring me
|
|

February 22nd, 2007, 01:53 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
A folder that exists in the current directory.
../dbase/file.mdb
tells the server that the dbase directory is one level higher then the current directory.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
|
|

February 22nd, 2007, 04:01 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Everybody,
I've been trying to work out some SQL / .asp interactions, where I have a form page that is populated by products in a database. On this page, I can successfully connect to database, and SQL works to the point where I can print a list of the prods to a page. On the page, each prod has a checkbox next to it. If you check some boxes and then hit send, the items checked are passed to another .asp page that handles the data. This page creates an SQL script that looks like
sql = "DELETE FROM prod WHERE listnum IN ("
...a loop fills the IN list with the request.form checkbox entries.
I continually get errors no matter WHAT I've tried on this data handler page.
Here is the code from the intial form page:
<%@ Language=VBscript %>
<% Option Explicit%>
<% Response.Buffer = true %>
<%
dim prod(100)
dim listnum(100)
dim c
c=1
Dim Conn, Rs, sql
sql = "SELECT * FROM prod"
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("milinternational.mdb")
Rs.Open sql, Conn
while not Rs.eof
prod(c) = Rs("product")
listnum(c) = Rs("listnum")
rs.movenext
c = c+1
wend
%>
<html>
<head>
<title>Mil International - Administrator Only</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table cellpadding="3" cellspacing="3" border="1" align="center">
<tr>
<td colspan="3">Mil International Products List</td>
</tr>
<tr>
<td></td><td>List #</td><td>Product Name</td>
</tr>
<% dim i
c = c-1
%>
<form action="delhandle2.asp" method="post">
<%for i = 1 to c %>
<tr>
<td><INPUT TYPE=CHECKBOX NAME="listnum" value="<%=listnum(i)%>"></td><td></td><td><% response.write(prod(i)) %> </td>
</tr>
<% Next %>
<input type="submit" name="submit" value="Send">
</form>
</table>
<%
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
%>
</body>
</html>
AND here is the code from the DATA handler page:
<%@ Language=VBscript %>
<% Option Explicit%>
<% Response.Buffer = true %>
<%
dim counter
counter=1
dim del(100)
dim x
dim del_list
dim add
del_list = ""
dim upper
upper=request.Form("listnum").count
Dim Conn, Rs, sql
sql = "DELETE FROM prod WHERE listnum IN ("
if upper >= 1 then
For counter = 1 To Request.Form("listnum").Count-1
del_list = del_list & Request.Form("listnum")(counter) & "," &""
Next
del_list=del_list+Request.Form("listnum")(counter)
end if
sql = sql&del_list&")"
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("milinternational.mdb")
Rs.Open sql, Conn
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
response.Redirect("index.html")
%>
Why can I succesfully open the DB and print from it in the first page...but in the 2nd page, something crashes? This leads me to believe that my connection to the DB is not the issue. I think it is the SQL. What do you think?
I did a test to see exactly what the SQL script was by simply response.write it to the screen...to make sure the loops and the request.form was working. This is the result(when checking only boxes 1 and 2):
DELETE FROM prod WHERE listnum IN (1,2)
I'm struggling here and getting frustrated. ANY help would be greatly greatly appreciated. Thank you for your time! : )
-Brian
|
|

February 22nd, 2007, 05:35 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes...but the only way I know of checking for this is by right-clicking on the .mdb file, selecting "properties" and un-checking the "read only" attribute. It is unchecked, but this is the extent of my knowledge as far as read/write permissions are concerned. I could be wrong?
thank you for your help,
brian
|
|
 |