Solved

OCDB CONNECTION

Posted on 2003-11-15
23
1,769 Views
Last Modified: 2007-12-19
I HAVE THE COONECTION TO MY DATABASE SET UP TO LOOK ON LOCAL DISC C:, BUT WHEN I TRY TO PROCESS THE ASP PAGE THE ERROR MESSAGE SAYS THAT THE PATH TO ANOTHER SERVER IN NOT VALID. I DO NOT HAVE IT SET UP TO LOOK AT THAT SERVER.
CAN SOMEONE EXPLAIN THIS, IS THE COMPUTER LOST?

I AM USING DREAMWEAVER MX, AN ASSESS DATABASE, AND AN OCDB SET UP FOR DRICE C:
0
Comment
Question by:jkleist
  • 7
  • 6
  • 6
  • +3
23 Comments
 
LVL 8

Expert Comment

by:SNilsson
Comment Utility
Check your ODBC connection in ODBC manager, then test it in Excel for example(using MS Query) if it behaves as expected then the error might be in your ASP code so please post your trouble code and we can have a look at it.

And btw is it not against the rules to type in caps only :)
0
 

Expert Comment

by:neel_07
Comment Utility
Make sure that the ODBC Driver that you are selecting is correct. At times there are multiple ODBC drivers for access databases. For example, there may be a "Microsoft Access Treiber" and aso a "Microsoft Access Driver". Make sure you   select the Microsoft Access "Driver" ODBC connection.

Also, check whether the ODBC connection that you are making is under the System DSN tab.
0
 
LVL 10

Expert Comment

by:D_M_D
Comment Utility
Are you using Server.MapPath("C:\yourdatabase.mdb") in your connection string?

If your database resides under your the root C:\ then this is a physical path and the Server.MapPath() uses virtual paths (under inetpub/wwwroot) the virtual path is based on the directory your currently in.  Please post your code.

--------
D_M_D
0
 
LVL 7

Expert Comment

by:wsteegmans
Comment Utility
Try this procedure on your WebServer (where your ASP-pages are stored).

Create in any folder on your webserver a new file with extension UDL, for example create 'test.udl' in your temp-folder.
Once created, double click on it ... The dialogbox 'Data Link Properties' is started.

Now, with this nice tool, make your connection to your SQL-Server, Access-DB or any other DB. Once configured and TESTED with the Test-Connection button, close this window.

Last step: Open this test.udl file in any Text-editor, for example NotePad. The last line in this file, starting with 'Provider ...' is your connectionstring. So copy/paste it in your ASP-file. Because we tested it in the 'Data Link Properties', it will work!

One remark. When building a connection-string (for ex. for SQL-Server) with a user that has a password, please activate the option 'Allow saving Password'. But when using an Access database, you don't need it ...

An additional link:
Guide to Database Connection Strings:
http://www.razza.com/support/kbarticle.asp?ID=2

One remark on this page, when programming ASP (VB-Script) and using MS Access, SQL-Server, I would always use the OLEDB-way to connect, because there are some disadvantages with ODBC.
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
Can you paste your code here

CJ
0
 

Author Comment

by:jkleist
Comment Utility
SELECT left([data1],3), mid([data1],4,15), mid([data1],19,30), mid([data1],49,9), mid([data1],58,2), mid([data1],60,6)
FROM webdata
WHERE left([DATA1],3)  LIKE 'ACC'  AND  mid([data1],4,15) LIKE '%MMM%'
ORDER BY left([data1],3) ASC, mid([DATA1],4,15) ASC

THIS IS THE QUERY ON THE DATABASE....
ACC AND MMM ARE VAIABLES THAT DEFINE FIELDS ON
THE INPUT ASP PAGE.
0
 
LVL 7

Expert Comment

by:wsteegmans
Comment Utility
jkleist,

This is your SQL-Statement ... We need your Connection-String, something like
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Folder1\dbname.mdb;Persist Security Info=False
0
 
LVL 10

Expert Comment

by:D_M_D
Comment Utility
Please post all of your code the whole page...

Thanks

--------
D_M_D
0
 

Author Comment

by:jkleist
Comment Utility
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/net.asp" -->
<!--#include file="Connections/stockcheck.asp" -->
<%
var stock_check__ACC = "%";
if (String(Request.Form("manufacturer")) != "undefined" &&
    String(Request.Form("manufacturer")) != "") {
  stock_check__ACC = String(Request.Form("manufacturer"));
}
%>
<%
var stock_check__MMM = "%";
if (String(Request.Form("itemnumber")) != "undefined" &&
    String(Request.Form("itemnumber")) != "") {
  stock_check__MMM = String(Request.Form("itemnumber"));
}
%>
<%
var stock_check = Server.CreateObject("ADODB.Recordset");
stock_check.ActiveConnection = MM_net_STRING;
stock_check.Source = "SELECT left([data1],3), mid([data1],4,15), mid([data1],19,30), mid([data1],49,9), mid([data1],58,2), mid([data1],60,6)  FROM webdata  WHERE left([DATA1],3)  LIKE '"+ stock_check__ACC.replace(/'/g, "''") + "'  AND  mid([data1],4,15) LIKE '%"+ stock_check__MMM.replace(/'/g, "''") + "%'  ORDER BY left([data1],3) ASC, mid([DATA1],4,15) ASC";
stock_check.CursorType = 0;
stock_check.CursorLocation = 2;
stock_check.LockType = 1;
stock_check.Open();
var stock_check_numRows = 0;
%>
<%
var Repeat1__numRows = 10;
var Repeat1__index = 0;
stock_check_numRows += Repeat1__numRows;
%>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>                                                            
function DoCurrency(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)                        
      DoCurrency = FormatCurrency(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)            
End Function                                                                                    
</SCRIPT>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>                              
function DoTrim(str, side)                                          
      dim strRet                                                
      strRet = str                                                
                                                            
      If (side = 0) Then                                    
            strRet = LTrim(str)                                    
      ElseIf (side = 1) Then                                    
            strRet = RTrim(str)                                    
      Else                                                      
            strRet = Trim(str)                                    
      End If                                                      
                                                            
      DoTrim = strRet                                                
End Function                                                      
</SCRIPT>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p><font size="+1" face="Arial, Helvetica, sans-serif"></font></p>
<p align="center">&nbsp;</p>
<p align="center"><strong><font size="+2" face="Arial, Helvetica, sans-serif">
  </font></strong></p>
<p align="center">&nbsp;</p>
<p align="left"><font size="+2" face="Arial, Helvetica, sans-serif"><strong>Stock
  Check Results</strong></font> </p>
<div align="left">
  <table border="1">
    <tr>
      <td><div align="center"><strong><font face="Arial, Helvetica, sans-serif">Mfg.</font></strong></div></td>
      <td><div align="center"><strong><font face="Arial, Helvetica, sans-serif">Item
          #</font></strong></div></td>
      <td><div align="center"><strong><font face="Arial, Helvetica, sans-serif">Description</font></strong></div></td>
      <td><div align="center"><strong><font face="Arial, Helvetica, sans-serif">Mfg.
          Retail</font></strong></div></td>
      <td><div align="center"><strong><font face="Arial, Helvetica, sans-serif">uom</font></strong></div></td>
      <td><div align="center"><strong><font face="Arial, Helvetica, sans-serif">O/H
          Qty.</font></strong></div></td>
    </tr>
    <% while ((Repeat1__numRows-- != 0) && (!stock_check.EOF)) { %>
    <tr>
      <td><div align="center"><font size="-1" face="Arial, Helvetica, sans-serif"><%= (stock_check.Fields.Item("Expr1000").Value).toUpperCase() %></font></div></td>
      <td><div align="left"><font size="-1" face="Arial, Helvetica, sans-serif"><%= DoTrim((stock_check.Fields.Item("Expr1001").Value),1) %></font></div></td>
      <td><div align="left"><font size="-1" face="Arial, Helvetica, sans-serif"><%=(stock_check.Fields.Item("Expr1002").Value)%></font></div></td>
      <td><div align="right"><font size="-1" face="Arial, Helvetica, sans-serif"><%= DoCurrency((stock_check.Fields.Item("Expr1003").Value), -1, -2, -2, -2) %></font></div></td>
      <td><div align="center"><font size="-1" face="Arial, Helvetica, sans-serif"><%=(stock_check.Fields.Item("Expr1004").Value)%></font></div></td>
      <td><div align="center"><font size="-1" color="BLUE" face="Arial, Helvetica, sans-serif"><strong><%=(stock_check.Fields.Item("Expr1005").Value)%></strong></font></div></td>
    </tr>
    <%
  Repeat1__index++;
  stock_check.MoveNext();
}
%>
  </table>
</div>
<p>To Check Another Item </p>
<p><a href="STOCK_CHECK.asp">Click Here</a></p>
</body>
</html>
<%
stock_check.Close();
%>
0
 
LVL 7

Expert Comment

by:wsteegmans
Comment Utility
This is were you connectioinstring is set:
stock_check.ActiveConnection = MM_net_STRING;

But we need the value of this variable, so I guess we need also the code of these files:
- Connections/net.asp
- Connections/stockcheck.asp

But, check first this code for usernames and passwords ... and remove them or replace them with 'userid' and 'password'
0
 

Author Comment

by:jkleist
Comment Utility
<%
// FileName="Connection_odbc_conn_dsn.htm"
// Type="ADO"
// DesigntimeType="ADO"
// HTTP="false"
// Catalog=""
// Schema=""
var MM_stockcheck_STRING = "dsn=stockcheck;"
%>




<%
// FileName="Connection_odbc_conn_dsn.htm"
// Type="ADO"
// DesigntimeType="ADO"
// HTTP="false"
// Catalog=""
// Schema=""
var MM_net_STRING = "dsn=net;"
%>
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
do you have a system DSN created called net?

CJ
0
 
LVL 7

Expert Comment

by:wsteegmans
Comment Utility
When using DreamWeaver MX, when creating a ConnectionString, you have this additional option:
DreamWeaver should connect:
  - Using Driver On Testing Server
  - Using Driver On This Machine

I don't know which option is selected, but it seems that you're using DSN's to connect your database. If the above option is set to Testing Server, check this Machine/Server if there is a DSN called 'stockcheck' and 'net' and also check them ...
If the option is set to This Machine (I suppose, because you write you set it up for drive C:) check your own DSN's ...

You can find your DSN-settings (if using W2K) here:
Control Panel -> Administrative Tools -> Data Sources (ODBC)

You must setup these datasources in the System DSN Tab ... Otherwise, they won't work when using in ASP-Pages ...
0
 

Author Comment

by:jkleist
Comment Utility
I do have stockcheck set up but not net. I do not have a databse called net nor do i have a connection named net
0
 
LVL 7

Expert Comment

by:wsteegmans
Comment Utility
You set your ActiveConnection to the 'net' DSN, like this in your code:
stock_check.ActiveConnection = MM_net_STRING;

I think you need the StockCheck DSN-Connection, so change this line like this:
stock_check.ActiveConnection = MM_stockcheck_STRING ;

Try it ...
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
do you even need net connection.

Try removing that line and see if it works.

From your code it seems like you are just doing stockcheck db stuff not anything else.

CJ
0
 

Author Comment

by:jkleist
Comment Utility
YES, IT IS JUST  A SIMPLE STOCK CHECK. THE ISSUE WE HAVE IS THE .dbf FILE IS ON A LOCKED DATABASE SYSTEM. I CAN EXTRACT THE DATA INTO A dbf FILE "FLAT LAYOUT", BUT WHEN
WE PUT IT ON OUR TEST SERVER IT RUNS VERY SLOW, SEQUENTIALLY SEARCHING FILE AS A dbf CONNECTION. IF I LINK THE DATABASE TO AN ACCESS mdb FILE, THE ODBC CANNOT FIND THE FILE. IT'S LIKE WE GET ONE ISSUE FIXED THEN ANOTHER GOES HAYWIRE..... WE WANT TO HAVE THE DATA AS UP TO DATE AS POSSIBLE, I HAVE AN AUTO DUMP FROM THE LOCKED SYSTEM EVERY HOUR, THEN HAVE SCHEDULER OVERWRITE THE CURRENT .dbf FILE ON THE SERVER. PART OF IT HAS TO DO WITH I.E. PERMISSIONS I THINK....I DON'T KNOW, THIS SHOULD HAVE BEEN AN EASY PROJECT...
0
 
LVL 7

Expert Comment

by:wsteegmans
Comment Utility
Your write:
IF I LINK THE DATABASE TO AN ACCESS mdb FILE, THE ODBC CANNOT FIND THE FILE.

But, you must create/adapt your DSN to this NEW Access-Database (with a different-name). Or did you do that ... ?
0
 

Author Comment

by:jkleist
Comment Utility
YES I DID RENAME IT, THE I.E. ERROR SAYS SOMETHING LIKE THIS the Microsoft jet databse engine cannot find the input table or query \webdata#dbf

they are both in the same dirctory, and access is linked to it.

????
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 500 total points
Comment Utility
did you create the linked access mdb on your dev server before uploading it to your test server?

One thing I found out about linked tables, MS access uses exact paths.  So if you link a file in your current directory..
lets say:
c:\inetpub\wwwroot\db\webdata.dbf

It must be in the SAME exact folder on the test server otherwise it cannot find the file.

What I usually end up doing is setting up my dev file/directory structure to be identical to my production/test server.

So if in my test server the mdb and dbf files will be
c:\inetpub\wwwroot\username\db

I will create the same exact directory on my dev server and create the mdb file there with the dbf file there.  Then upload it.

CJ
0
 

Author Comment

by:jkleist
Comment Utility
Thanks, I'll try it tonight. First I'll dump what I've got out there to avoid errors, and start from scratch...I'll advise tomorrow.
sounds like the correct answer.
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
yeah, its was a pain for me as it took me a while to figure it out as I got the basic- table not found error too :-)

Keep us posted.

CJ
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
Glad to help and Thnx for the "A"

CJ
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Read about why website design really matters in today's demanding market.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now