Skip to main content
October 27, 2006
Question

OLEDB

  • October 27, 2006
  • 3 replies
  • 330 views
Hello,


I have seen connectionstrings.com and I guess I am feeling dumb. So how do I go about changing this code to work with OLEDB. right now this code works great on my machine but i never works on my host's machine.

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/myCars.asp" -->
<%
var csSold_cars__MMColParam = "Y";
if (String(Request("MM_EmptyValue")) != "undefined" &&
String(Request("MM_EmptyValue")) != "") {
csSold_cars__MMColParam = String(Request("MM_EmptyValue"));
}
%>
<%
var csSold_cars = Server.CreateObject("ADODB.Recordset");
csSold_cars.ActiveConnection = MM_myCars_STRING;
csSold_cars.Source = "SELECT * FROM [Car Details] WHERE Sold LIKE '%"+ csSold_cars__MMColParam.replace(/'/g, "''") + "%'";
csSold_cars.CursorType = 0;
csSold_cars.CursorLocation = 2;
csSold_cars.LockType = 1;
csSold_cars.Open();
var csSold_cars_numRows = 0;
%>
<%
var Repeat1__numRows = 3;
var Repeat1__index = 0;
csSold_cars_numRows += Repeat1__numRows;
%>

1) do in need a connections/mycars.asp page with OLEDB?
2) connection strings gives the following

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:System Database=system.mdw;"

3) personally i don't care if I am ODBC or OLEDB but I can't get this to work on my providers website so I am going to try anything.

4) this code was basically selecting one recordset and filtering out the cars with "Y" in one of the fields. I just have no clue why this is so easy on my local machine but never works on my hosts machine. I am just praying I can get a bit of help here. Thank you and have a good night.
This topic has been closed for replies.

3 replies

Inspiring
October 27, 2006
I'd strongly suggest that you switch to VB Script. It's much easier to learn
for beginners. Anyway, in Javascript, you need to escape backslashes, so
you'd have:

MM_CharonCart_STRING = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=
c:\\virtualroot\\cartv3\\db\\charoncart3.mdb"

--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004



dave_asp wrote:
> So now i have the ollowing code:
>
> <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
> <!--#include file="Connections/myCars.asp" -->
> <%
> var csSold_cars__MMColParam = "Y";
> if (String(Request("MM_EmptyValue")) != "undefined" &&
> String(Request("MM_EmptyValue")) != "") {
> csSold_cars__MMColParam = String(Request("MM_EmptyValue"));
> }
> %>
> <%
> MM_myCars_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=C:\Accounts\automixm\wwwRoot\Private\cars_database.mdb" & ";Jet
> OLEDB:System Database=system.mdw;"
> %>
> <%
> var csSold_cars = Server.CreateObject("ADODB.Recordset");
> // csSold_cars.ActiveConnection = MM_myCars_STRING;
> csSold_cars.Source = "SELECT * FROM [Car Details] WHERE Sold LIKE '%"+
> csSold_cars__MMColParam.replace(/'/g, "''") + "%'";
> csSold_cars.CursorType = 0;
> csSold_cars.CursorLocation = 2;
> csSold_cars.LockType = 1;
> // csSold_cars.Open();
> var csSold_cars_numRows = 0;
> %>
>
>
> I commented out
> // csSold_cars.ActiveConnection = MM_myCars_STRING;
> // csSold_cars.Open();
>
> because I was getting errors. I hate asking for so much help. These
> growing
> pains are killing me. luckily I have 6 books in the mail. FYI
> abebooks.com IS
> GREAT.


October 27, 2006
So now i have the ollowing code:

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/myCars.asp" -->
<%
var csSold_cars__MMColParam = "Y";
if (String(Request("MM_EmptyValue")) != "undefined" &&
String(Request("MM_EmptyValue")) != "") {
csSold_cars__MMColParam = String(Request("MM_EmptyValue"));
}
%>
<%
MM_myCars_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Accounts\automixm\wwwRoot\Private\cars_database.mdb" & ";Jet OLEDB:System Database=system.mdw;"
%>
<%
var csSold_cars = Server.CreateObject("ADODB.Recordset");
// csSold_cars.ActiveConnection = MM_myCars_STRING;
csSold_cars.Source = "SELECT * FROM [Car Details] WHERE Sold LIKE '%"+ csSold_cars__MMColParam.replace(/'/g, "''") + "%'";
csSold_cars.CursorType = 0;
csSold_cars.CursorLocation = 2;
csSold_cars.LockType = 1;
// csSold_cars.Open();
var csSold_cars_numRows = 0;
%>


I commented out
// csSold_cars.ActiveConnection = MM_myCars_STRING;
// csSold_cars.Open();

because I was getting errors. I hate asking for so much help. These growing pains are killing me. luckily I have 6 books in the mail. FYI abebooks.com IS GREAT.

Inspiring
October 27, 2006
The path to the data source has to be absolute, including drive letter and
path. You're probably best to use Server.MapPath() to get this since you
don't always know where your host is putting things:

MM_myCars_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("\somepath\mydb.mdb") & ";Jet OLEDB:System
Database=system.mdw;"

Server.MapPath() converts a relative or virtual path into a drive path that
the driver can interpret properly, i.e.
"d:\somedirectory\somepath\mydb.mdb".

Best regards,
Chris