Hello all,
I'm somewhat familiar with ASP, SQL and VBScript... Sooo.. I can get it done, but somehow I think there is a better way than I am thinking.
I am trying to create a page for people to add multiple line items to a request. I have two tables set up in a many-to-one relationship. tblRequest and tblRequestDetail - tblRequest
-
RequestID; Autonumber; Indexed No Dupes
- CustomerID; PK
-
CustomerTicket; PK (multiple customers can have the same ticket number, but no one customer can have the same ticket number, so this is how the PK is related)
-
Etc;
-
- tblRequestDetail
- RequestDetailID; PK; AutoNumber
-
RequestID; FK
-
ProductID;
-
ModelID;
-
etc;
-
I am a little weary on how to set up the "Request Form"... Especially when it comes to handling the insert of the data in the tblRequestDetail table.
Do I have to call a SELECT tblRequest.RequestID FROM tblRequest WHERE ((tblRequest.CustomerTicket = X) AND (tblRequest.CustomerID = Y)) to insert the value into tblRequestDetail.RequestID??
Maybe I can just do an INSERT INTO.... WHERE ((tblRequest.CustomerTicket = X) AND (tblRequest.CustomerID = Y)) after I call the .Update from the first insert of the tblRequest table??
I don't want to really go headlong into this (it's my first attempt at creating an insert form) and be going the wrong direction.
THANK YOU!!!!
5 1204
I have created the following testform... -
<% If Request.Form("CustomerID")<>"" And Request.Form("CustomerTicket")<>"" Then %>
-
<% Dim rs, sql, reqID %>
-
<% Set rs = server.createObject("adodb.recordset") %>
-
<% sql = "SELECT * FROM tblRequest" %>
-
<% rs.open sql, Conn,2,3 %>
-
-
<%=Request.Form("CustomerID") %> <br />
-
<%=Request.Form("CustomerTicket") %> <br />
-
<%=Session("Logon") %> <br />
-
<%
-
rs.addNew
-
rs("EnteredByNet") = Session("Logon")
-
rs("CustomerID") = CInt(Request.Form("CustomerID"))
-
rs("CustomerTracking") = Request.Form("CustomerTicket")
-
rs("RequestTypeID") = 1
-
rs.update
-
rs.close
-
-
sql = "SELECT tblRequest.RequestID FROM tblRequest WHERE tblRequest.CustomerID = 1 AND tblRequest.CustomerTracking=""" & Request.Form("CustomerTicket") & """"
-
rs.open sql, Conn, 2, 3
-
reqID = rs("RequestID")
-
rs.close
-
-
sql = "SELECT * FROM tblRequestDetail"
-
rs.open sql, Conn, 2, 3
-
rs.addNew
-
rs("RequestID") = reqID
-
rs("ProductID") = 39
-
rs("EnteredByNet") = Session("Logon")
-
rs.update
-
%>
-
-
<% Else %>
-
<form action="request.asp" method="post">
-
<input name="CustomerID" type="text" />
-
<input name="CustomerTicket" type="text" />
-
<input name="" type="submit" />
-
</form>
-
<% End If %>
-
It's not very clean, and not very efficient (proof of concept design)...
What I really need to do is generate something that first asks for the information in the tblRequest table, and once that is input have a new section display, that shows tblRequestDetail table information. To display something like.... -
<table width="85%" border="1">
-
<tr>
-
<td>tblRequest.CustomerID</td>
-
<td>tblRequest.CustomerTicket</td>
-
<td>tblRequest.LocationCode</td>
-
<td>tblRequest.EnteredBy</td>
-
<td>tblRequest.ReqType</td>
-
</tr>
-
<tr>
-
<td> </td>
-
<td>tblRequestDetail.ProductID</td>
-
<td>tblRequestDetail.Qty</td>
-
<td>tblRequestDetail.Serial</td>
-
<td>tblRequestDetail.Type</td>
-
</tr>
-
<tr>
-
<td> </td>
-
<td>tblRequestDetail.ProductID</td>
-
<td>tblRequestDetail.Qty</td>
-
<td>tblRequestDetail.Serial</td>
-
<td>tblRequestDetail.Type</td>
-
</tr>
-
<tr>
-
<form action="request.asp" method="post">
-
<td><input type="submit" value="Add New" /></td>
-
<td><input name="tblRequestDetail.ProductID" type="text" /></td>
-
<td><input name="tblRequestDetail.Qty" type="text" /></td>
-
<td><input name="tblRequestDetail.Serial" type="text" /></td>
-
<td><input name="tblRequestDetail.Type" type="text" /></td>
-
</form>
-
</tr>
-
</table>
-
See the last row in the table would have the ability to add more items to the request. I am merely looking for guidance on where to go with the selection structure to accomplish a pseudo-shopping cart? Any help is greatly appreciated.
you havent mentioned the names of the files which code is in which file atleast mention it so that we could further see that code
Regards,
Omer
Thanks for the reply. :) (Even though it didn't show up when I hit "Reply" it showed me your quoted text.)
I'll give you as much information as possible. -
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
-
<%
-
If Session("Logon") = "" Then
-
Session("LastPage") = Request.ServerVariables("URL")
-
Response.Redirect("login.asp")
-
End if
-
%>
-
<!--#include file="connstr.asp"-->
-
<!--#include file="includes\common.asp"-->
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>Request New</title>
-
</head>
-
-
<body>
-
<% If Request.Form("CustomerID")<>"" And Request.Form("CustomerTicket")<>"" Then %>
-
<% Dim rs, sql, reqID %>
-
<% Set rs = server.createObject("adodb.recordset") %>
-
<% sql = "SELECT * FROM tblRequest" %>
-
<% rs.open sql, Conn,2,3 %>
-
-
<%=Request.Form("CustomerID") %> <br />
-
<%=Request.Form("CustomerTicket") %> <br />
-
<%=Session("Logon") %> <br />
-
<%
-
rs.addNew
-
rs("EnteredByNet") = Session("Logon")
-
rs("CustomerID") = CInt(Request.Form("CustomerID"))
-
rs("CustomerTracking") = Request.Form("CustomerTicket")
-
rs("RequestTypeID") = 1
-
rs.update
-
rs.close
-
-
sql = "SELECT tblRequest.RequestID FROM tblRequest WHERE tblRequest.CustomerID = 1 AND tblRequest.CustomerTracking=""" & Request.Form("CustomerTicket") & """"
-
rs.open sql, Conn, 2, 3
-
reqID = rs("RequestID")
-
rs.close
-
-
sql = "SELECT * FROM tblRequestDetail"
-
rs.open sql, Conn, 2, 3
-
rs.addNew
-
rs("RequestID") = reqID
-
rs("ProductID") = 39
-
rs("EnteredByNet") = Session("Logon")
-
rs.update
-
rs.close
-
%>
-
<% Else %>
-
<form action="request.asp" method="post">
-
<input name="CustomerID" type="text" />
-
<input name="CustomerTicket" type="text" />
-
<input name="" type="submit" />
-
</form>
-
<% End If %>
-
<table width="85%" border="1">
-
<tr>
-
<td>tblRequest.CustomerID</td>
-
<td>tblRequest.CustomerTicket</td>
-
<td>tblRequest.LocationCode</td>
-
<td>tblRequest.EnteredBy</td>
-
<td>tblRequest.ReqType</td>
-
</tr>
-
<tr>
-
<td> </td>
-
<td>tblRequestDetail.ProductID</td>
-
<td>tblRequestDetail.Qty</td>
-
<td>tblRequestDetail.Serial</td>
-
<td>tblRequestDetail.Type</td>
-
</tr>
-
<tr>
-
<td> </td>
-
<td>tblRequestDetail.ProductID</td>
-
<td>tblRequestDetail.Qty</td>
-
<td>tblRequestDetail.Serial</td>
-
<td>tblRequestDetail.Type</td>
-
</tr>
-
<tr>
-
<!-- This is the part that I need to be able to add multiple lines to the Request -->
-
<!-- Maybe I'm hoping it will be short and easy, but there really is a lengthy loop involved, is there not? -->
-
<form action="request.asp" method="post">
-
<td><input type="submit" value="Add New" /></td>
-
<td><input name="tblRequestDetail.ProductID" type="text" /></td>
-
<td><input name="tblRequestDetail.Qty" type="text" /></td>
-
<td><input name="tblRequestDetail.Serial" type="text" /></td>
-
<td><input name="tblRequestDetail.Type" type="text" /></td>
-
</form>
-
</tr>
-
</table>
-
-
</body>
-
</html>
-
Hello all,
Maybe I can just do an INSERT INTO.... WHERE ((tblRequest.CustomerTicket = X) AND (tblRequest.CustomerID = Y)) after I call the .Update from the first insert of the tblRequest table??
I don't want to really go headlong into this (it's my first attempt at creating an insert form) and be going the wrong direction.
THANK YOU!!!!
you cannot use WHERE clause in the insert statement in the SQL query
I realized that not too long after I wrote it when I tried. The HTML I provided showed a different approach that is working now, but I still need help creating the form. I thought it would be easy, but it's not being too easy.
So far what I have works... Using a SELECT of the PK(s) in the related table. However, I am thinking I may want to try for an array set-up, before sending the update to the table (can do error checking and everything in the array first).
I am stumped at how to create a form that will allow me to continuously add new items to it, though. Any guidance there? It would be similar to a shopping cart, except users select from a drop down menu what they want to add. Update the quantity and add any additional notes.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ford Desperado |
last post by:
I've been reading the docs and playing around, but I'm still not
getting the difference. For instance,
create table a(i int check(i>0))
create table a_src(i int)
go
create unique index ai on...
|
by: Daniel Tan |
last post by:
I got a syntax error in SQL insert into statement , hope someone can
help me .Thanks.
job_search = "='" & Me.Jobno & "' "
sqlstr = "INSERT INTO Custorder (job_order) " & _
"values " &...
|
by: Bruce A. Julseth |
last post by:
A couple of questions about a Generated Insert Procedure.
1. Why is there a "SELECT " statement after the insert?
2. This SELECT statement has "WHERE (PrimaryKey = @@IDENTITY)". I "assume"...
|
by: shenanwei |
last post by:
I have 2 same windows machine, same instance configure and Database ,
all run DB2 UDB V8.1.5
Test 1 :
create table OUT_1 (LINE VARCHAR(350), LINENUMBER INTEGER NOT NULL
GENERATED ALWAYS AS...
|
by: fintudet |
last post by:
Hello.
During some experimentation with DB2 decimal numbers representations, I
have discovered very unexpected behaviour of the global temporary
table. Consider this example.
Such I had...
|
by: mosscliffe |
last post by:
I created a new table in Visual Web Developer for SQL Server Express
2005. I created a 'gridview' by dragging the table onto an empty web
form in Visual Developer Express.
Clicked on the smart...
|
by: macupryk |
last post by:
{System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_ProjectResponse__ProjectQuestionId". The conflict occurred in database "RG_ProjectData", table...
|
by: Mark Knochen |
last post by:
Hello,
i have a php-script with a mysql_query ...
$insert = mysql_query("INSERT INTO $table (textID,redaktion) VALUES
('$_POST','$row_startseiten')");
I get no mysql_error, if i copy the...
|
by: Ultrak The DBA |
last post by:
As a converted sybase dba, I have a question. In sybase a command can
be executed multiple times by placing a
go 1000
at the end of the statement. Such as:
insert into a (col1, col2)...
|
by: mdboldin |
last post by:
I hav read on this forum that SQL coding (A) below is preferred over
(B), but I find (B) is much faster (20-40% faster)
(A)
sqla= 'INSERT INTO DTABLE1 VALUES (%d, %d, %d, %f)' % values...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |