Link to home
Start Free TrialLog in
Avatar of jkleist
jkleist

asked on

OCDB CONNECTION

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:
Avatar of SNilsson
SNilsson
Flag of Sweden image

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 :)
Avatar of neel_07
neel_07

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.
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
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.
Can you paste your code here

CJ
Avatar of jkleist

ASKER

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.
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
Please post all of your code the whole page...

Thanks

--------
D_M_D
Avatar of jkleist

ASKER

<%@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();
%>
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'
Avatar of jkleist

ASKER

<%
// 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;"
%>
do you have a system DSN created called net?

CJ
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 ...
Avatar of jkleist

ASKER

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
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 ...
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
Avatar of jkleist

ASKER

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...
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 ... ?
Avatar of jkleist

ASKER

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.

????
ASKER CERTIFIED SOLUTION
Avatar of cheekycj
cheekycj
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
Avatar of jkleist

ASKER

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.
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
Glad to help and Thnx for the "A"

CJ