CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Inserting into two tables

Print topic Send  topic

Author Message
Mark H
Posted: 04/20/2004, 8:10 PM

Hi all,

I am trying to use code charge studio for solving the following problem:

I need a simple search, view and insert/update screen no problem it took 5 miniutes, what I also nee to to is to write to some of the data entered in another table when either inserted or updated.

Can you point me in the right direction, I have now spent more time doing this than it woulh have taken by hand, but next time I am sure it will only take 7 min for the whole thing so I hope you can help. :-)

Mark H
peterr


Posts: 5971
Posted: 04/21/2004, 1:56 AM

I would actually recommend doing this part by hand...
You can save time doing a lot of things in CCS but certain things still should be done by hand and since you know how to do it (based on your posting) then this may be the way to go.
I understand though that you'd like details on how to get the most without coding and how to write compact code that takes advantage of CCS functionality.
I don't know how your tables are structured and what type of page or forms you are implementing, but here is the code sample that should be sufficient to update 2nd table in the "After Update" event of the page:
  
Dim SQL  
Dim Connection  
  
  SQL = "INSERT INTO secon_table(key_id, field1) "&_   
        "VALUES ("& CCToSQL(FormName.key_id.Value,ccsInteger) &","& CCToSQL(FormName.field1.Value,ccsText) &")"  
  
  Set Connection = New clsDBConnection1  
  Connection.Open  
  Connection.Execute(SQL)  
  Connection.Close  
  Set Connection = Nothing  
(assuming that key_id and field1 are the names of your database fields and controls on the page, while database connection is named Connection1)

When inserting records you sometimes may need to retrieve the key of the record inserted automatically by CCS into the 1st table.
The sample code for this is in our "Multi-Step Registration form" example:
LastID = CCDLookup("max(user_id)","users","user_login="&DBInternetDB.ToSQL(Request.Form("user_login"),"CCText"),DBInternetDB)
However, if your database supports it, you should replace "max(user_id)" with the database function that retrieves the actual last inserted key.

The "ShoppingCart" page in our "Store" example ( http://docs.codecharge.com/studio/html/ProgrammingTechn...SSolutions.html ) should be a good example to look at as well. In this example you can see custom code in the sever "OnClick" event, which copies records from the shopping cart table into the order table, then deletes them from the shopping cart. I think that very similar code can be used in most cases, especially in the "After Insert" and "After Update" events of Record forms.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.