Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is wrong in this code ?
Message
From
27/09/2001 11:56:17
 
General information
Forum:
Internet
Category:
Active Server Page
Miscellaneous
Thread ID:
00561454
Message ID:
00561502
Views:
30
>Hi All,
>
>I am getting an error with the following code, can any one advice me what is wrong in this code, the error I get on line "rstGuestBook.AddNew"
>the aim of this code is, will add a new record to my GuestBook.mdb File.
>
>this is the code:
>
>Set myConn = Server.CreateObject("ADODB.Connection")
>myConn.Open "2bs-GuestBook"
>mySql = "SELECT * FROM GuestBook"
>Set rstGuestBook = myConn.Execute(mySql)
>
>rstGuestBook.AddNew
>
>rstGuestBook("Nmae") = Request.Form("txtName")
>rstGuestBook("Email") = Request.Form("txtEmail")
>rstGuestBook("Company") = Request.Form("txtCompany")
>rstGuestBook("Url") = Request.Form("txtUrl")
>rstGuestBook("Comment") = Request.Form("txtComment")
>
>rstGuestBook.Update
>
>rstGuestBook.Close
>Set rstGuestBook = Nothing
>
>myConn.Close
>Set myConn = Nothing
>
>Response.Redirect("guest_book_Thanks.html")
>
>
>BR


Where's your connection string ?

On a design point of view:
You should not open a recordset to add a new record. It waste precious ressources for no good reasons.
You should open you Connection and execute an INSERT query or open a Connection, create a Command object and call a store procedure.
Guy Barrette, MCSD
============
Blog http://weblogs.asp.net/guybarrette
Microsoft Regional Director, Montreal, Canada www.microsoft.com/rd
MVP, ASP.NET http://mvp.support.microsoft.com/
President, Montreal Visual Studio User Group www.guvsm.net
INETA Regional Rep for Quebec www.ineta.org
UniversalThread Magazine Columnist (.NET Books Review Column) www.utmag.com
Tech Chair French Track, DevTeach 2004 & 2005 www.devteach.com
Business Architect, Microsoft Team - Nurun Inc www.nurun.com
XBox Live Gamer Tag: Slomo QC CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform