Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > Dreamweaver (all versions)
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) 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
 
Old January 14th, 2005, 06:19 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to config db connection in a DSN-less server

I used DW MX2004 to created couple of form collection info and info display ASP pages, with an Access db. DW auto generated connection file as always. It worked fine in my local. When I upload to 1and1 host server, I found out they can't add DSN to ODBC. Instead, they give following code as connection samples:

<%
Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
OBJdbConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("../db/products.mdb") & ";"
SQLQuery = "SELECT * FROM PRODUCTS"
Set RS = OBJdbConnection.Execute(SQLQuery)
%>


In DW, code for connection is

Set OBJdbConnection = Server.CreateObject("ADODB.Recordset")
OBJdbConnection.ActiveConnection = MM_dsnname_STRING

And that MM_dsnname_STRING is calling a dsn set in ODBC.

Since I've already have these pages done, I try to avoid to redo the codes. Is there anyway to define "MM_dsnname_STRING" with the connection sample 1and1 gives?

appreciate for any help!


 
Old January 15th, 2005, 05:31 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Sure, you can. Right now, MM_dsnname_STRING is filled with a reference to the DSN. All you need to do is replace it with a proper connection string.

The one your ISP gave is very old and *not* recommended. Try this instead in your connection file:

MM_dsnname_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
   "Data Source=" & Server.Mappath("../db/products.mdb") & ";" & _
   "User Id=admin;" & _
   "Password="

Then your code can stay the same:

OBJdbConnection.ActiveConnection = MM_dsnname_STRING

Instead of accepting a DSN name, and doing a lookup for the database info, the connection now gets a proper OleDb connection directly.

Make sure you adjust the path in Server.MapPath tp match the path you're calling this code from.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: I Wanna be Adored by The Stone Roses (Track 1 from the album: The Stone Roses) What's This?
 
Old November 5th, 2006, 08:15 AM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The power of a Google search.

Thanks for the connection string.

Using it I got my database on 1and1 working with my Dreamweaver .asp pages

Now the only issue is in Dreamweaver my local and remote connection pages differ. I guess in the future I could sim the 1and1 dir structure on my local IIS server so the connection string will be the same.

Thanks again:)
John aka KJ6TK

 
Old November 6th, 2006, 03:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, you could do that.

Alternatively, you can store the connection string in the global.asa file and never overwrite that file when you update the site.

Or you can Server.MapPath as I suggested in an earlier post. Server.MapPath takes a virtual path and maps it to a physical path. So, Server.MapPath("Databases") could be c:\yoursite\Databases on your local system and something like D:\webs\customers\YourCompany\YourSite\Databases on the production server.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old June 27th, 2008, 06:45 PM
Registered User
 
Join Date: Jun 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Guys,

I am having a similar problem and attempted to follow this post but I was unsuccessful.

I have a local site developed in ASP with an access database which is working fine however when I uploaded it to 1and1 I realized that I should of left development to the pro's =(

I have the following script in my connection file generated in Dreamweaver MX:

<%
// FileName="Connection_odbc_conn_dsn.htm"
// Type="ADO"
// DesigntimeType="ADO"
// HTTP="false"
// Catalog=""
// Schema=""
var MM_user_logins_STRING = "dsn=user_logins;"
%>

1and1 provides the following example script.


<html>
<title>Database query using ASP</title>
<body bgcolor="FFFFFF">
<h2>Query table <b>Products</b> with ASP</h2>
<%
Set dbaseConn = Server.CreateObject("ADODB.Connection")
dbaseConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("\db\products.mdb") & ";"
SQLQuery = "SELECT * FROM PRODUCTS"
Set RS = dbaseConn.Execute(SQLQuery)
%>
<%
Do While Not RS.EOF
%>
<%=RS("name")%>, <%=RS("description")%>, <%=RS("price")%> DM
<p>
<%
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
dbaseConn.Close
Set dbaseConn = Nothing
%>
</body>
</html>


http://faq.1and1.com/scripting_langu...atabase/2.html

I am a little bit lost and attempted the following script:

<%
// FileName="Connection_odbc_conn_dsn.htm"
// Type="ADO"
// DesigntimeType="ADO"
// HTTP="false"
// Catalog=""
// Schema=""
var MM_user_logins_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
   "Data Source=" & Server.Mappath("../db/mydb.mdb") & ";" & _
   "User Id=admin;" & _
   "Password="
%>


The script didn't work and I received the following Message:

Microsoft JScript runtime error '800a1391'

'_' is undefined

/Connections/user_logins.asp, line

Any direction you guys can provide would be greatly appreciated. (This script is for a login page)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Using DB Connection from Config file Snuffles ASP.NET 2.0 Basics 1 March 28th, 2007 06:18 AM
DSN Connection mred2nice Visual Studio 2005 0 October 31st, 2006 11:58 AM
Need DSN Connection Code to Access DB markw707 ASP.NET 1.0 and 1.1 Basics 0 May 13th, 2005 09:10 AM
dsn-less connection problem Justine SQL Server ASP 3 March 8th, 2004 01:45 PM
config.php file (define "DSN" ) confusion paddy PHP Databases 3 July 8th, 2003 07:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.