Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms...silly question no doubt!

Status
Not open for further replies.

stevemarsh99

Technical User
Aug 10, 2005
88
GB
I have a page that I want to update a record in one table of a db but in the same db, i want to insert a record to another table, all at the same time and maybe in the same form?

is this possible and if not there must be a way-around?
 
you can do everything on a single page...something like this

Dim con 'con connection object
con="your connection string here"
sql1="update query"
sql2="insert query"

con.execute (sql1)
con.execute(sql2)

-DNG
 
Sorry could you explain more? just i am a dreamweaver wizard man here, my sql knowledge is weak at best :p
 
what i was trying to show is, you can execute two sql statements one after the other without any problem...

-DNG
 
what dotnetgnat means is that in the same page you can open a connection, write different queries (update, delete, insert...) referring to different tables in the same db or even in different db if you open more than one connection, and then execute all queries.

in your case, assuming that you have a form with two controls "user", "password", and two tables, one with login users and the other with a login log

you can

dim COnn, strSQL1, strSQL2,

set conn = server.createobject("ADODB.connection")

'update query that updates the user's last login date
strSQL = "update loginlog SET lastlog = '" & date & "' where username = '" & request("user") & "' and password = '" & request("password") & ""


'insert query to add a new login
strSQL2 = "insert into logintable (user, password) values ('" & request("user") & "' , '" & request("password") & "')"


now execute the queries
conn.execute strSQL1
conn.execute strSQL2

response.write("All done!")

conn.close
set conn = nothing


While this example does not make much sense as you would not log a user's login and then create his own login, it should however give you a hint on how to run different queries in the same page.

CHeers


QatQat

Life is what happens when you are making other plans.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top