Addnew Problem with Excel

From: Stan the Mouse (StantheMouse_at_discussions.microsoft.com)
Date: 10/31/04


Date: Sun, 31 Oct 2004 02:03:02 -0800

I try to use the addnew function to fill my Excel Recordset, but all the
empty fields in my recordset will be filled (not 1 record) until it is full.

How to tell use this addnew function to fill only 1 record?

Thanks

Here is my code:

CurPage = cint(Request.QueryString("Page"))
if CurPage<=0 then CurPage=1

if request.form("Topic") <> "" then

   Set Guestobject = Server.CreateObject("ADODB.Connection")
     GuestObject.Open "DBQ=" & Server.MapPath("guestbook.xls") & ";" &
"DRIVER={Microsoft Excel Driver (*.xls)}; ReadOnly=False; IMEX=2; Extended
Properties=Excel 8.0;"
   Set rs = Server.CreateObject("ADODB.Recordset")
     rs.Open "SELECT * FROM guest;", GuestObject, 1,3

   ' GuestObject.Open "DRIVER={Microsoft Access Driver (*.mdb)};dbq=" &
Server.MapPath("GuestBook.mdb")'

   Mail = Request.Form("Mail")
   HomePage = Right(Request.Form("Homepage"),len(Request.Form("Homepage"))-7)
   if Len(Mail) < 10 then Mail=""
   if Len(Homepage) <10 then HomePage=""

' SQL = "INSERT INTO Guest(fldDateTime, fldTopic, fldName, fldFace,
fldMail, fldHomepage, fldContent) VALUES('" & Now() & "','" &
Request.Form("Topic") & "','" & Request.Form("Name") & "','" &
Request.Form("Sale") & Request.Form("Face") & "','" & Mail & "','" & Homepage
& "','" & Request.Form("Content") & "')"
' Set RS=GuestObject.Execute(SQL)

        rs("fldDateTime")=now()
        rs("fldTopic")=Request.Form("Topic")
        rs("fldName")=Request.Form("Name")
        rs("fldFace")=Request.Form("Face")
        rs("fldMail")=Mail
        rs("fldHomepage")=Homepage
        rs("fldContent")=Request.Form("Content")

   rs.addnew

   guestobject.Close
   response.redirect "guest1.asp"
else



Relevant Pages

  • Re: Addnew Problem with Excel
    ... "Stan the Mouse" wrote in message ... >I try to use the addnew function to fill my Excel Recordset, ...
    (microsoft.public.data.ado)
  • Re: RecordSet without actual data behind it
    ... "Agoston Bejo" wrote in message ... Actually it needs to be a RecordSet only ... > because it is a perfect choice as data structure for what I want to do, ... > add rows by the AddNew function, or try to add fields to it. ...
    (microsoft.public.data.ado)
  • Re: RecordSet without actual data behind it
    ... "Agoston Bejo" wrote in message ... Actually it needs to be a RecordSet only ... > because it is a perfect choice as data structure for what I want to do, ... > add rows by the AddNew function, or try to add fields to it. ...
    (microsoft.public.inetserver.asp.db)
  • Re: RecordSet without actual data behind it
    ... "Agoston Bejo" wrote in message ... Actually it needs to be a RecordSet only ... > because it is a perfect choice as data structure for what I want to do, ... > add rows by the AddNew function, or try to add fields to it. ...
    (microsoft.public.inetserver.asp.general)
  • Re: RecordSet without actual data behind it
    ... "Agoston Bejo" wrote in message ... Actually it needs to be a RecordSet only ... > because it is a perfect choice as data structure for what I want to do, ... > add rows by the AddNew function, or try to add fields to it. ...
    (microsoft.public.vb.database.ado)