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

 After Insert - Error

Print topic Send  topic

Author Message
ekendricks

Posts: 34
Posted: 07/17/2005, 5:34 PM

I tried to follow the Store example in doing custom insert - update - delete. So far I've not been successful on the first phase - insert.

Using Access 2K CCS
I get error : Operation Not Allowed when the Object is closed:

Function Employees_AfterInsert() 'Employees_AfterInsert @2-B41D0C45

'Custom Code @100-73254650
' -------------------------
Dim Sql
Dim RecordSet
Dim EmpID

'Get EmpID From Table "Employees"
'This method compatible with all databases (unsafe when multiple users insert records at the same time)
'Use your own method for your database.
SQL = "SELECT MAX(EmpID) FROM Employees"
Set RecordSet = DBMed.Execute(SQL)
EmpID = CCGetValue(RecordSet, 0)


'Add Record to table ezUser
SQL = "SELECT EmpID, UserName, Pswd, Email, PhoneHome, Admin" _
& "FROM Employees " _
& "WHERE EmpID = " & DBMed.ToSQL(Request.Cookies("EmpID"),ccsInteger)
Set RecordSet = DBMed.Execute(SQL)


While NOT Recordset.EOF
SQL = "INSERT INTO ezUser (EmployeeID, UserID, Password, Email, Phone, Admin ) " _
& "VALUES (" & DBMed.ToSQL(EmpID,ccsInteger) _
& "," & DBMed.ToSQL(CCGetValue(RecordSet, "UserName"),ccsText) _
& "," & DBMed.ToSQL(CCGetValue(RecordSet, "Pswd"),ccsText) _
& "," & DBMed.ToSQL(CCGetValue(RecordSet, "Email"),ccsText) _
& "," & DBMed.ToSQL(CCGetValue(RecordSet, "PhoneHome"),ccsText) _
& "," & DBMed.ToSQL(CCGetValue(RecordSet, "Admin"),ccsBoolen) _
& ")"
DBMed.Execute(SQL)
Recordset.MoveNext
Wend
' -------------------------
'End Custom Code

If someone would be so kind as to tell me what I've done wrong, I would greatly appreciate it. Hopefully the update - delete function won't be as bad.

Thanks
View profile  Send private message
smalloy

Posts: 107
Posted: 07/18/2005, 6:32 AM

It looks like you never instantiate the database object.

Put this code before your code:

'Declare Variables  
Dim DBMed  
  
'Open the database  
Set DBMed = New clsDBMed  
DBMed.Open

And this After:

'Clean Up  
If DBMed .State = adStateOpen Then _  
    DBMed .Close  
    Set DBMed = Nothing  

You should be fine!
_________________
Anything can be done, just give me time and money.
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.

Web Database

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.