ASP Database Help

psuchad

Guppy
I am new to asp and am having trouble connecting to an Access database. I have a test page with only the following.

<% Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=D:\hshome\username\databasename.mdb%>

I get the following error:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/untitled3.asp, line 7

Provider=Microsoft.Jet.OLEDB.4.0;
----------------------------^

Could anyone please help me out? I am also having trouble figuring out how Dreamweaver needs to be configured.
 
Not to sound rude, but you really need to study up on asp first before embarking on your task. The example you've given lacks the very basics of programming knowledge.. again, not meaning to be rude, but I doubt anyone has time to teach the basics of programming here.

May I suggest a few resources which might start you off:

DevGuru Tutorial - A Beginner's Guide to Using Active Server Pages

and a good basic reference site for the language:

ASP Tutorial

connecting to an Access database and examples:

ASP Connecting To An Access Database

and for more advanced stuff:

4GuysFromRolla.com - Frequently Asked Questions!

I found these just by Googling the relevant topics. Remember Google is your friend! Everything - and I mean everything - you need to know about ASP is there on the net. Just Google your questions and you will find answers.

Being a good developer starts with being able to solve problems. Which, in many cases, means skillful use of Google. :)

hope that helps
 
Not to be rude to you, but I am not new to programming. I am just new to asp. I have done research on how to connect to an access database. I have even gotten some references when I submitted a ticket for the database path. Those references all tell me to use the above code. And I am getting an error. Therefore I am asking for help.

Do not pass judgement on my developer or problem solving skills as you my friend do not know me. Part of solving problems is asking questions, which is all I did.
 
The stuff inside the <% %> needs to be valid VBScript code. i.e., executable statements. What you have there is a connection string which ASP is trying to interpret as VBScript and making no sense of it. Those links antic gave seem to have some good examples.

Ross
 
Not to be rude to you, but I am not new to programming. I am just new to asp. I have done research on how to connect to an access database. I have even gotten some references when I submitted a ticket for the database path. Those references all tell me to use the above code. And I am getting an error. Therefore I am asking for help.

Do not pass judgement on my developer or problem solving skills as you my friend do not know me. Part of solving problems is asking questions, which is all I did.

if you can post the code here i can take a look and see what might be missing. or even PM it to me since people on here appear to be more worried about commenting on programmer skill level than actually trying to help.
 
:)

Feel free to post the code, the people here are friendly but may not have come across as such today :D
 
but, but not complete, and while it was not good code, some other assistance could be provided with more complete code :)
 
Sorry to have caused some concern about helpfulness on this topic. I did take the trouble to help, as I think is evident by my post and the links provided. Apologies if I misinterpreted the level of the question, no offence intended. :grouphug: :)
 
OK, yet another unhelpful post from me, but I couldn't resist.
If you don't know ASP yet and are apparently starting some project from scratch, I would suggest you invest that time into learning ASP.NET instead.
Learning all of .NET is a bigger undertaking than learning ASP, but it's more useful knowledge nowadays.

Ah well, what the heck..

Code:
' config.asp
Const ConfigIncluded = 1
Const DatabaseConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\hshome\username\databasename.mdb"

' Some other file
<!-- #INCLUDE file="config.asp" -->

Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
		
With Conn
	.ConnectionString = DatabaseConnectStr 
	.ConnectionTimeout = 10
	.Open
End With

' ... database queries and stuff :)

The "Const ConfigIncluded = 1" at the start of config.asp doesn't really have anything to do with connecting to the database, but it's a habit I've picked up in the past. Should you ever accidentally include the config.asp twice and show the error message to the user, it would otherwise expose the connection string. Not so much a problem with Access maybe, but if you ever use a real database it might expose passwords and such ;)
This line ensures that the error would occur on a otherwise useless part of the configuration file.

Of course you're free to dump everything in one file, but I suggest you make use of include files in any project that uses more than 1 page. I just demonstrated it here because the method to include in ASP has nothing to do with ASP itself and might otherwise take you a while to find :)
 
If you don't know ASP yet and are apparently starting some project from scratch, I would suggest you invest that time into learning ASP.NET instead.

Good point, now that there's a free dev tool. It may actually be easier - simply dropping in the db control and setting the properties.
 
Back
Top