Solved

Opening a connection to a delimited text file

Posted on 1998-11-16
3
185 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

770 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