Solved

Opening a connection to a delimited text file

Posted on 1998-11-16
3
184 Views
Last Modified: 2013-12-25
I am creating a form that figures out shipping costs based on where the I am shipping from, the destination shipping location, the shipping method, and the weight. I am keeping this information in a text file that is connected to only when the form results page is accessed. I've seen numberous examples for Access and SQL Server how to do this but not for a text file. Once I open it, how do I get a row of data from it to compare it to the values (see case statement)

Below is my Formresults code:

<%@ Language=VBScript %>
<html>

<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title></title>
</head>

<body>
<% dim v_get_cost
dim v_total_cost
dim v_from_location
dim v_to_location
dim v_weight
dim v_shipping_type

v_from_location = Request.form("from_location")
v_to_location = Request.Form("to_location")
v_weight = Request.Form("weight")
v_shipping_type = Request.Form("shipping_type")

Select Case v_shipping_type
Case "LTL"
      v_get_cost = (select LTL_cost from testdata.txt where from_location = v_from_location and to_location = v_to_location and v_weight between min_weight and max_weight;)
      v_total_cost = v_weight * v_get_cost
Case "AIR"
      v_get_cost = (select AIR_cost from testdata.txt where from_location = v_from_location and to_location = v_to_location and v_weight between min_weight and max_weight;)
      v_total_cost = v_weight * v_get_cost
Case "TL"
      v_get_cost = (select TL_cost from testdata.txt where from_location = v_from_location and to_location = v_to_location and v_weight between min_weight and max_weight;)
      v_total_cost = v_get_cost
End Select
%>

<p>You have chosen to ship from <%=v_from_location%> to <%=v_to_location%>.<br>
The weight of the shipment is <%=v_weight%><br>
The desired shipping method is <%=v_shipping_type%><br>
<br>
The total cost of shipping is <%=v_total_cost%><br>
</p>

<p>process another shipping cost</p>
</body>
</html>


Here's the text file:

From_location,To_location,Min_Weight,Max_Weight,LTL,AIR,TL
MI,AZ,0,99,0.43,0.8,3246
MI,AZ,100,199,0.18,0.75,3246
MI,FL,0,99,0.32,0.8,1818

Any help you can give would be appreciated...
0
Comment
Question by:aguldber
  • 2
3 Comments
 

Author Comment

by:aguldber
ID: 1856406
Edited text of question
0
 
LVL 1

Accepted Solution

by:
rajgn earned 70 total points
ID: 1856407
You cannot Query a TEXT file as you do with any database. But the task you're looking for can be accomplished using a text file also(but is labourious). In this case you need to store data in Text file in a specific format(with suitable delimiters), and have to retrieve the data from it based on the format you're storing. For this you need to use TextStream object and FileFileSystemObjects.
0
 

Author Comment

by:aguldber
ID: 1856408
Sorry it's taken so long for me to grade, I thought I did it when I first read you answer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Optimum versions of Selenium Webdriver with Python On Windows 7 1 80
cookies analysis tools 2 69
Urgent Help with HTML CSS Positioning 9 41
remove border from element 5 52
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 …
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 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

18 Experts available now in Live!

Get 1:1 Help Now