p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   INSERT & SELECT FROM....? No idea (http://p2p.wrox.com/showthread.php?t=12959)

Seb_soum May 13th, 2004 04:18 PM

INSERT & SELECT FROM....? No idea
 
hi guys

I need to insert seom details into a Access DB. thats no problem. I do need to have a drop down list showing usernames from another table. The value from the drop down is passed onto the other table. How do I do this? Can I have 2 SQL statements on 1 page?
EG. SELECT * FROM Users & INSERT INTO Main......etc

bmains May 13th, 2004 05:46 PM

You can have two sql statements. Let me see if I understand; first you select the users and use the drop down box, then when the user selects an option, you want to then insert information into another table?

You can have 2 statements sure, the select is a select into a recordset, and to do the insert you can do connection.execute(SQL).

Brian

Brian

Seb_soum May 14th, 2004 05:35 AM

Could you give me an axample.....sorry, I've tried to find this kind of code on the net, but nothing so far......I'm pretty limited in ASP.

Any help you could give me would be appreciated

bmains May 14th, 2004 07:06 AM

set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnectionString
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open ("select * from Users", objConn)

do while (not objRS.EOF)
  objConn.Execute("insert into Main (userID, page) values ('" & objRS("UserID") & "', '" & Request.ServerVariables("SCRIPT_NAME") & "')")
  objRS.MoveNext
loop

Something like that. Although what are you trying to do?


All times are GMT -4. The time now is 11:48 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.