Page 310 - DCAP408_WEB_PROGRAMMING
P. 310
Web Programming
Notes ObjRS.AddNew
ObjRS(“Name”) = “Nikhil”
ObjRS(“Email”) = xyz@asd.com
ObjRS.AddNew
ObjRS(“Name”) = “Aman”
ObjRS(“Email”) = “asd@xyz.com”
ObjRS.Update
Another way of initializing the variables using AddNew is
Syntax :— objRS.AddNew fields, values
Fields and values are either single values or arrays with the same number of elements.
For example objRS.AddNew Array(“Name”, “Email”), Array(“Nikhil”, xyz@asd.com)
Adding a Record Using AddNew and Update
1. <%@ Language=VBScript %>
2. <! - - #include virtual=*/adovbs.inc”—> %>
3. <! - - #include file=*DatabaseConnect.asp”—>
4. <HTML>
5. <BODY>
6. <%
7. Dim objRS
8. Set objRS = Server.CreateObject(“ASOSB.Recordset”)
9. objRS.Open “tblUsers”,objConn, , AdLockOptimistic, adCmdTable
10. objRS.AddNew
11. objRS(“FirstName”) = “Nikhil”
12. ObjRS(“Email”) = xyz@asd.com
13. objRS(“Username”) = “aaa”
14. objRS(“Password”) = “pwd”
15. objRS.Update
16. objRS.MoveFirst
17. %>
18. <B> Entries in Table</B>
19. <P>
20. <TABLE>
21. <TR>
22. <TD> Name </TD>
23. <TD> Email</TD>
24. <TD> Username</TD>
304 LOVELY PROFESSIONAL UNIVERSITY