Link to home
Start Free TrialLog in
Avatar of rderidder
rderidder

asked on

ASP <=> Paradox

How can I set up a ADO connection directly to a paradox database (containing 4 tables (8 files)) in an ASP?
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

<!— #Include file="ADOVBS.INC" —>
<% Language = VBScript %>
<HTML><HEAD>
<TITLE>ADO 1.5 Open Method</TITLE></HEAD>
<BODY>
<FONT FACE="MS SANS SERIF" SIZE=2><Center><H3>ADO AddNew Method</H3>
<!— ADO Connection Object used to create recordset—><%
'Create and Open Connection Object
Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
OBJdbConnection.Open "AdvWorks"
'Create and Open Recordset Object
Set RsCustomerList = Server.CreateObject("ADODB.Recordset")
RsCustomerList.ActiveConnection = OBJdbConnection
RsCustomerList.CursorType = adOpenKeyset
RsCustomerList.LockType = adLockOptimisticRsCustomerList.Source = "Customers"
RsCustomerList.Open%>
<!— If this is the first time the page is opened, the Form collection will be empty when data is entered run AddNew method—><%
If Not IsEmpty(Request.Form) Then
    If Not Request.Form("CompanyName") = "" Then        
        RsCustomerList.AddNew
        RsCustomerList("CompanyName") = Request.Form("CompanyName")
        RsCustomerList("ContactLastName") = Request.Form("LastName")
        RsCustomerList("ContactFirstName") = Request.Form("FirstName")
        RsCustomerList("PhoneNumber") = Request.Form("PhoneNumber")
        RsCustomerList("City") = Request.Form("City")
        RsCustomerList("StateOrProvince") = Request.Form("State")
        RsCustomerList.Update        
        RsCustomerList.MoveFirst                End IfEnd If%>
<TABLE COLSPAN=8 CELLPADDING=5 BORDER=0>
<!— BEGIN column header row for Customer Table—>
<TR><TD ALIGN=CENTER BGCOLOR="#008080">
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Company Name</FONT></TD>
<TD ALIGN=CENTER BGCOLOR="#008080">
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Contact Name</FONT></TD>
<TD ALIGN=CENTER WIDTH=150 BGCOLOR="#008080">
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Phone Number</FONT></TD>
<TD ALIGN=CENTER BGCOLOR="#008080">
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>City</FONT></TD>
<TD ALIGN=CENTER BGCOLOR="#008080">
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>State/Province</FONT></TD></TR>
<!—Display ADO Data from Customer Table One row on each pass through recordset—>
<% Do While Not RsCustomerList.EOF %>    <TR><TD BGCOLOR="f7efde" ALIGN=CENTER>
  <FONT STYLE="ARIAL NARROW" SIZE=1>
      <%= RSCustomerList("CompanyName")%>       </FONT></TD>
  <TD BGCOLOR="f7efde" ALIGN=CENTER>      <FONT STYLE="ARIAL NARROW" SIZE=1>
      <%= RScustomerList("ContactLastName") & ", " %>
      <%= RScustomerList("ContactFirstName") %>       </FONT></TD>
  <TD BGCOLOR="f7efde" ALIGN=CENTER>      <FONT STYLE="ARIAL NARROW" SIZE=1>
     <%= RScustomerList("PhoneNumber")%>      </FONT></TD>
  <TD BGCOLOR="f7efde" ALIGN=CENTER>      <FONT STYLE="ARIAL NARROW" SIZE=1>
      <%= RScustomerList("City")%>       </FONT></TD>
  <TD BGCOLOR="f7efde" ALIGN=CENTER>      <FONT STYLE="ARIAL NARROW" SIZE=1>
      <%= RScustomerList("StateOrProvince")%>       </FONT></TD></TR>
<!— Next Row = Record Loop and add to row html table—><%
RScustomerList.MoveNext Loop %></TABLE><HR>
<!— Form to enter new record posts variables back to this page —><Table>
<Form Method = Post Action="AddNew.asp" Name=Form><TR><TD><P>Company Name:</TD>
<TD><Input Type="Text" Size="50" Name="CompanyName" Value = ""></P></TD>
<TR><TD><P>Contact First Name:</TD>
<TD><Input Type="Text" Size="50" Name="FirstName" Value = ""></P></TD>
<TR><TD><P>Contact Last Name:</TD>
<TD><Input Type="Text" Size="50" Name="LastName" Value = ""></P></TD>
<TR><TD><P>Contact Phone:</TD>
<TD><Input Type="Text" Size="50" Name="PhoneNumber" Value = ""></P></TD>
<TR><TD><P>City:</TD>
<TD><Input Type="Text" Size="50" Name="City" Value = ""></P></TD>
<TR><TD><P>State / Province:</TD>
<TD><Input Type="Text" Size="5" Name="State" Value = ""></P></TD>
<TR><TD><Input Type="Submit" Value="Add New "><Input Type="Reset" Value="Reset Form">
</Form></Table></Center></FONT>
<%'Show location of DSN data source
Response.Write(OBJdbConnection)%>
<Script Language = "VBScript">Sub Form_OnSubmit
    MsgBox "Sending New Record to Server",,"ADO-ASP _Example"
      End Sub
      </Script>
</BODY></HTML>
I should have included the correct ODBC driver;

Driver={Microsoft Paradox Driver *.db)};DBQ=physical path to .db file;DriverID=26
Avatar of rderidder
rderidder

ASKER

Could you tell me where exactly this Driver line should go?
Say the file will be in the current directory (the same as the ASP), and there are db files for Inventory, Warehouse, Employee, and Location.
Thanks,
rderidder
And, I am assuming this microsoft driver comes included with IIS, or NT, and I don't have to find it anywhere?

THanks,
rderidder
Are you going to use Server DSN connections?  Or do you want these conections to be DSNless?  Are you going to Join or Link these tables?
You assume correctly.
I was going to have them DSNless, not even using ODBC if possible?
Is there a way to use a virtual directory set up on the webserver? - Doubt it. Otherwise, no..DSNless.

No joins. SImple queries involving one table at a time - 4 database connections going I guess.
ASKER CERTIFIED SOLUTION
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One last detail..

Shouldn't ".\file.db" work as the path to the current directory (the directory where the ASP resides)?

How can I create the ASP so that it can be installed on different machines, with different directory structures, and package it with the db files, and not have to worry about changing the code to reflect the different directory structures?

It seems ".\file.db" doesn't work.
Actually, it seems I can use a virtual directory in the server.mappath. SO I can set up the IIS web server to have this virtual directory and point it to wherever I want.
Perfect.
Thanks
Is file.db located in the same directory path as the .asp file?  If so you can use this, "./file.db" or "file.db".  Other wiase use common UNC paths.  If there is a directory under the .asp page called data, and the dB file is locted there, use the path "./data/file.db" or "/data/test.db"  

As to your secong part it is up to you to package the directory paths, or you can create paths dynamically using FSO... but o really don't want to get into this right now...  it would require a bit of work. Other than that you will have to set the paths to the dB if the tree's are diferent on each machine.

Mark
Yup... you can do that!  :-)
One more problem with this..
Hope you are still reading...
It works fine on my Win 98 , with a personal web server.
But now that I've tried it on my web server with IIS, it is not working.

I get :
Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I think it is a driver thing. Does this method use the ODBC driver ODBCJT32.dll?
The IIS server has this driver, so I don't know what is wrong.

The open string I use is:
objDC.Open "DBQ=" & Server.MapPath(".\location.db") & ";Driver={Microsoft Paradox Driver *.db)};"

Though, I've even tried a direct path, without the mappath thing. Still doesn't work.
I don't get why it is telling me about data sources...

Is there an issue with IIS and ISAM drivers??
What version of ODBC are you using?  You will be able to check to see if the Paradox driver is even loaded by looking in the ODBC properties under drivers.  You may have to update the ODBC driver.

Here is a great reference for the error you are recieving.

http://support.microsoft.com/support/kb/articles/Q183/0/60.ASP