Addnew Problem with Excel
From: Stan the Mouse (StantheMouse_at_discussions.microsoft.com)
Date: 10/31/04
- Next message: Mark J. McGinty: "Re: how to use GetRows() with VBscrip (ASP)?"
- Previous message: Mich: "Re: how to use GetRows() with VBscrip (ASP)?"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Mark J. McGinty: "Re: how to use GetRows() with VBscrip (ASP)?"
- Previous message: Mich: "Re: how to use GetRows() with VBscrip (ASP)?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|