Solved

Opening a connection to a delimited text file

Posted on 1998-11-16
3
183 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
Comment Utility
Edited text of question
0
 
LVL 1

Accepted Solution

by:
rajgn earned 70 total points
Comment Utility
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
Comment Utility
Sorry it's taken so long for me to grade, I thought I did it when I first read you answer
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

743 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

19 Experts available now in Live!

Get 1:1 Help Now