|
 |
asp_databases thread: insert problem
Message #1 by lodris@m... on Tue, 22 May 2001 21:37:53
|
|
I have 3 tables that i am using for this query -the only problem is that
im confused as how to start it.I have a dropdownlist whose contents are
generated from the table trade.Its only one record and thats the name its
pulling up for todays date.I want a user to be able to select the name it
wants to buy and for that information to be stored in another table
sharesuser along with the price which is still in the trade table.How do i
get that from the trade table to the sharesuser table when the user
presses the submit button.
The other problem is I am trying to use a session variable that was set at
the login page to insert into the db at a later stage can this be done
code is below.If not does anyone have any ideas how i could do it.
set strSQL =conn.execute ("INSERT INTO sharesuser ( UserName, ShareOption,
Quantity, Price , Date_bought ) VALUES ( Session("strLogin") ,'"&
StockName& "','" & Quantity & "','" & LastTrade & "','" & now() & "' )")
Thanks
Leigh
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 23 May 2001 10:39:46 +1000
|
|
VALUES ('" & session("strLogin") & "', '" & Stockname & "', "
etc
You writing literal text (session("strLogin")) into your SQL statement. You
want to insert the value of a variable instead.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: <lodris@m...>
To: "ASP Databases" <asp_databases@p...>
Sent: Tuesday, May 22, 2001 9:37 PM
Subject: [asp_databases] insert problem
: I have 3 tables that i am using for this query -the only problem is that
: im confused as how to start it.I have a dropdownlist whose contents are
: generated from the table trade.Its only one record and thats the name its
: pulling up for todays date.I want a user to be able to select the name it
: wants to buy and for that information to be stored in another table
: sharesuser along with the price which is still in the trade table.How do i
: get that from the trade table to the sharesuser table when the user
: presses the submit button.
: The other problem is I am trying to use a session variable that was set at
: the login page to insert into the db at a later stage can this be done
: code is below.If not does anyone have any ideas how i could do it.
:
: set strSQL =conn.execute ("INSERT INTO sharesuser ( UserName, ShareOption,
: Quantity, Price , Date_bought ) VALUES ( Session("strLogin") ,'"&
: StockName& "','" & Quantity & "','" & LastTrade & "','" & now() & "' )")
:
: Thanks
: Leigh
Message #3 by lodris@m... on Wed, 23 May 2001 22:56:13
|
|
I cant seem to get this to insert the quantity value into my sql server
databse can you see why?
The quantity value is a text boc for user input on a different page
where the other inputted value is a dropdown list thats dynamically
generated from the database.The quantity field is a numeric datatype im
my database.
Thanks
Leigh
---------------------
Code for quantity
--------------------
</SELECT>
<b> Quantity </b> </font> <font size="3">
<input type="number" name="quantity" size=20 maxlength=50
value="">
</font></b></p>
<p>
<input type="submit" value="Submit" name="submit">
----------------------
Code on insert into database page
-----------------------------------
dim stock
stock = Request.QueryString("StockName")
quant = Request.QueryString("quantity")
dim rst, conn, strSQL,rs,rs1
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=project; uid=lodris-ca4; pwd=lodris1141;"
set rst=server.CreateObject("ADODB.Recordset")
set rst = conn.execute ("Select
StockName,Bid,Offer,LastTrade,PreviousClose,NetChange,TradeTime,TradeDat
e,getday FROM trade WHERE StockName = '" & stock & "' AND (getday = '"&
Date & "')")
set rs = conn.execute("select LastTrade from trade where StockName = '"
& stock & "' AND (getday = '"& Date & "') ")
pricevariable = rs ("LastTrade")
set strSQL =conn.execute ("INSERT INTO sharesuser ( UserName,
ShareOption, Quantity, Price, Date_bought ) VALUES ( '" &
Session("strLogin") & "' ,'"& stock& "','" & quant & "',"& pricevariable
& ",'" & now() & "' )")
|
|
 |