ASP - Connecting to MS Access DB, Where am i going wrong!

Associate
Joined
12 Aug 2004
Posts
1,009
Location
Glasgow, Scotland
Hi there,

Trying to connect to an MS Access database using classic ASP and i can't seem to produce any results :confused:, i'm going by the book and it just doesn't want to work...

All the names for the database and DSN connection seem to spelt correctly, there must be something to do with the ASP syntax that i'm missing :confusing:

Thanks for any help :)

Error Message
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment
Website/index.asp, line 55

DatabaseConnect.asp
Code:
<%
	Dim objConn
	Set objConn = Server.CreateObject("ADODB.Connection")
	objConn.ConnectionString = "DSN=littercode_cms"
	objConn.Open
%>

index.asp
Code:
<%@ Language=VBScript %>
<%  Option Explicit %>
<!--#include file="Connections/DatabaseConnect.asp"-->
<%
	Const adOpenForwardOnly = 0
	Const adLockOptimistic = 3
	Const adLockPessimistic = 2
	Const adLockReadOnly = 1
	Const adCmdTable = 2
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<meta name="description" content="insert variable for website description here" />
		<meta name="keywords" content="insert variable for website keywords" />
		<title>Untitled</title>
		<link rel="stylesheet" type="text/css" title="default" href="styles.css">

		<script language="JavaScript1.2" type="text/javascript">
			function clearDefault(el)
			{
				if (el.defaultValue==el.value) el.value = ""
			}
		</script>
	</head>
	
	<body>
		<div id="header"></div>
		<div id="wrapper">
			<div id="logoheader">
				<div id="logoheaderleft">
					<h1>Test Header</h1>
				</div>
				<div id="logoheaderright">
					<div id="logoheaderlinks">
						<a href="#" title="">Home</a> &nbsp;&nbsp;
						<a href="#" title="">About</a> &nbsp;&nbsp;
						<a href="#" title="">Sitemap</a> &nbsp;&nbsp;
						<a href="#" title="">Contact</a>
					</div>
					<div id="search-textonly">
					</div>
				</div>
			</div><!-- end of logoheader-->
			<div id="navheader">
				<%
					Dim objRS
					Set objRS = Server.CreateObject ("ADODB.Recordset")
					objRS.Open "tblMenu", objConn, , , adCmdTable
				%>
				<ul>
					<%Do While Not objRS.EOF%>
						<li><a href="index.asp?pg=<%objRS("IntLinkAddress")%>" title="<%objRS("Name")%>"%>><%objRS("Name")%></a></li>
						<%objRS.MoveNext%>
					<%Loop
						'closing the recordset connection
						objRS.Close
						Set objRS = Nothing
					%>
				</ul>
			</div><!-- end of navheader -->
			<div id="navlower">
				<form action="" method="post" name="search" class="searchform">
					<input type="text" name="search" value="Start new search" onfocus="javascript:clearDefault(this)" class="searchinput" /><input type="submit" name="searchs" id="" class="searchsubmit" value="Go" />
				</form>
				<a href="#" title="Text-only" class="textonly">Text-only</a>
			</div>
			<div id="leftcol">
				<ul>
					<li><a href="#">Sub Section 3</a></li>
					<li><a href="#">Sub Section 3</a></li>
					<li><a href="#">Sub Section 3</a></li>
					<li><a href="#">Sub Section 3</a></li>
					<li><a href="#">Sub Section 3</a></li>
					<li><a href="#">Sub Section 3</a></li>
					<li><a href="#">Sub Section 3</a></li>
					<li><a href="#">Sub Section 3</a></li>
					<li><a href="#">Sub Section 3</a></li>
				</ul>
			</div>
			<div id="rightcol">

			</div>
			<div id="footer">footer test</div>
		</div><!-- end of #wrapper -->
	</body>
</html>

<%
	'close the dsn connection
	objConn.Close
	Set objConn = Nothing
%>
 
anyone? :( ... i'm using MS Access 97 if that helps, not sure how compatible it is as its the old database format.
 
Yeah, just asked my boss and he said the exact same thing, and also showed me a few shortcuts to use when opening the dsn connection and record sets :)

Thanks for the help :)
 
Isn't using a DSN-less connection far less secure?, as it provides direct access to the database.
 
Back
Top Bottom