If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Dreamweaver to Access Database Connection String

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-15-07, 08:46
birdy247 birdy247 is offline
Registered User
 
Join Date: Mar 2007
Posts: 9
Question Dreamweaver to Access Database Connection String

Hi guys.

I have got myself some free web space at prohosting.com I have managed to upload some files through dreamweaver to the space using the ftp function. My next step is trying to create a connection to my Access Database.

I have created a file called Database on the server, and have placed my database in here. I have then tried to create a connection string to this by trying variuos connection strings, but i keep getting "unidentified error occoured"

I would appreciate any help.

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-15-07, 09:35
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 03-15-07, 10:34
birdy247 birdy247 is offline
Registered User
 
Join Date: Mar 2007
Posts: 9
Hi, i am still a little confuse though. How do i find out the path of my database held on the server? At the moment i right click on it and view the URL. Is this the right way?
Reply With Quote
  #4 (permalink)  
Old 03-15-07, 10:36
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
That sounds good to me...

Remember, if the webpage using the database is in the same folder then you can simply use the filename.
If it's in a subfolder to the webpage then you can use "\sub folder\databasename.mdb"
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 03-16-07, 08:58
birdy247 birdy247 is offline
Registered User
 
Join Date: Mar 2007
Posts: 9
Hi. I have tried everything and have still had no luck. Just to let you know, i am using the dreamweaver custom connection string window to try and connect. These are the strings i have used so far

"sDSN="Provider=Microsoft.Jet.IKEDB.4.0;Data
Source=\Database\database.mdb"

"driver={microsoft access driver(*.mdb)}; dbq=/Database/database.mdb"

The ftp testing server works fine, so i know all those setting are correct. My database is called Database.mdb held in a file called Database. Which is a sub directory of where my main site is held.

Really struggling with this.

Thanks
Reply With Quote
  #6 (permalink)  
Old 03-16-07, 09:04
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
I'm afraid my experience of ASP is fairly limited but let's see what we can achieve...
Give this code a bash:
HTML Code:
<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open "Database/database.mdb"

....

conn.close
Set conn = Nothing
%>
Let me know how it goes.
__________________
George
Twitter | Blog

Last edited by gvee; 03-16-07 at 09:16.
Reply With Quote
  #7 (permalink)  
Old 03-16-07, 09:11
birdy247 birdy247 is offline
Registered User
 
Join Date: Mar 2007
Posts: 9
Hi, thanks for quick reply. Where do i need to put that code exactly? Up until now i have simply been using dreamwevaer and inputting the connection string into a text box where it prompts me to.
Reply With Quote
  #8 (permalink)  
Old 03-16-07, 09:29
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
I have stumbled across this article which explains how to use dreamweaver to connect to an access database.

As for where to put that code - anywhere you want to use that datasource!

Here's an extended example
Save this code as an asp page (make sure you change the path to your database and table name to your own) and then run it and view the results.
HTML Code:
<html>
<body>
<%
dim conn, rs, x
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "<path to your database>"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM <YourTable>", conn
do until rs.EOF
  for each x in rs.Fields
    Response.Write(x.name)
    Response.Write(" = ")
    Response.Write(x.value & "<br />") 
  next
  Response.Write("<br />")
  rs.MoveNext
loop
rs.close
conn.close
Set rs = Nothing
Set conn = Nothing
%>
</body>
</html>
__________________
George
Twitter | Blog
Reply With Quote
  #9 (permalink)  
Old 03-16-07, 09:36
birdy247 birdy247 is offline
Registered User
 
Join Date: Mar 2007
Posts: 9
Nope, still not working. No idea what it is. Think it must be a really simple porblem, just doing my head in! Always errors and says unidentified error.
Reply With Quote
  #10 (permalink)  
Old 03-16-07, 09:38
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
HTML Code:
<% language="VBScript" %>
<% Option Explicit %>
<html>
<body>

....
I think the option explicit will help with the debug.
What did you change <path to your database> and <YourTable> to?
__________________
George
Twitter | Blog
Reply With Quote
  #11 (permalink)  
Old 03-16-07, 09:39
birdy247 birdy247 is offline
Registered User
 
Join Date: Mar 2007
Posts: 9
Wait a minute! Think i just found the problem. My server does not allow the file extension .asp. therefore i am guessing this is why it is erroring! Does anybody know of any good free servers that allow .asp pages and supports a ftp facility?
Reply With Quote
  #12 (permalink)  
Old 03-16-07, 09:53
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Haha, after all that eh?
Don't suppose you are running windows 200 Pro/Xp Pro/Vista? If so there's something called IIS which comes with it that works as like an emulation server for ASP pages. (useful for practice!).
And to answer your question - no, I'm afraid I do not know of any FREE ones that allow asp pages.
__________________
George
Twitter | Blog
Reply With Quote
  #13 (permalink)  
Old 03-16-07, 13:50
birdy247 birdy247 is offline
Registered User
 
Join Date: Mar 2007
Posts: 9
Right. Next problem encountered.

I have now got my self some new space. Which accepst access databases and asp pages. They even gave me a connection string to use. Which followed the lines of.

"PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("Database\TestDB.mdb")

I adapted this to the correct folder and file. However, when i ran the code in dreamweaver, it errord with "HTTP Error Code 400 Bad Request"

I then decided to try and use the exact location of my database. So i made a map path page which returned the following address of my database

e:\xxxxxxx\LocalUser\xxxxxxx\xxxxxxx.somee.com\dat abase\database.mdb

So i am now confident i have the exact location. Can anyone help with why it is erroring when i click "test connection"
Reply With Quote
  #14 (permalink)  
Old 03-16-07, 14:03
birdy247 birdy247 is offline
Registered User
 
Join Date: Mar 2007
Posts: 9
Quote:
Originally Posted by georgev
I have stumbled across this article which explains how to use dreamweaver to connect to an access database.

As for where to put that code - anywhere you want to use that datasource!

Here's an extended example
Save this code as an asp page (make sure you change the path to your database and table name to your own) and then run it and view the results.
HTML Code:
<html>
<body>
<%
dim conn, rs, x
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "<path to your database>"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM <YourTable>", conn
do until rs.EOF
  for each x in rs.Fields
    Response.Write(x.name)
    Response.Write(" = ")
    Response.Write(x.value & "<br />") 
  next
  Response.Write("<br />")
  rs.MoveNext
loop
rs.close
conn.close
Set rs = Nothing
Set conn = Nothing
%>
</body>
</html>
Just used that, and it comes up with a list of items in a table in my database. So the connection is fine. Its just dreamweaver errors when i try and use the connection string. Any ideas why??
Reply With Quote
  #15 (permalink)  
Old 03-19-07, 04:13
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Because WYSIWYG editors are poop
If you know the above connection string is working then just use that - don't try and re-invent the wheel!
and good luck with the project!
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On