Newbie needs help! Please!

Results 1 to 3 of 3

Thread: Newbie needs help! Please!

  1. #1
    Join Date
    Dec 1969

    Default Newbie needs help! Please!

    I am trying to add a record to a database via a form. Although the page is displaying without errors, the record is not being added. Here is the code I&#039;m using - what am I doing wrong?<BR>Thanks in advance!<BR><BR>&#060;%<BR> Response.buffer = true <BR> Dim RS<BR> Dim Conn<BR> Dim Mysql<BR> Dim ConnStr<BR> Dim SqlStr<BR> Dim frmSubmitStr<BR> <BR> ConnStr = "DSN=propertychoosercouk_dianedsn"<BR> Set Conn=Server.CreateObject("ADODB.Connection")<BR> Conn.Open ConnStr<BR><BR> Set RS=server.createobject("ADODB.Recordset")<BR> <BR> frmSubmitStr=Request.Form("frmSubmitStr")<BR> If request.QueryString("submit")&#060;&#062; "" then<BR> frmSubmitStr=request.QueryString("Submit")<BR> End if<BR> <BR> <BR> if frmSubmitStr &#060;&#062;"" then<BR> mySQL = "select * from Guestbook"<BR> RS.Open MySql, conn, adOpenStatic, adLockOptimistic<BR> RS.MoveLast<BR> RS.AddNew<BR> RS("name")= Request.Form ("name")<BR> RS("email")= Request.Form("email")<BR> RS("date")=Request.Form("date")<BR> RS("comment")=Request.Form("comment")<BR> <BR> RS.Update<BR> RS.Close<BR> set RS = nothing<BR> Conn.Close<BR> Conn = nothing<BR> End if<BR> %&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Newbie needs help! Please!

    frmSubmitStr=Request.Form("frmSubmitStr")<BR>If request.QueryString("submit")&#060;&#062; "" then<BR>frmSubmitStr=request.QueryString("Submit") <BR>End if<BR><BR>what are you doing here?<BR>if you want to retrieve the querystring value only if there is no value in the form element, then try this-<BR><BR>frmSubmitStr=Request.Form("frmSubmitStr")< BR>If frmSubmitStr= "" then<BR>frmSubmitStr=request.QueryString("Submit") <BR>End if<BR><BR>it&#039;s quite possible that your variable wasn&#039;t getting any value, hence it wasn&#039;t getting into the if-condition that was adding the record.

  3. #3
    Join Date
    Dec 1969

    Default How does the querystring coming into picture..

    ..when all the other form elements are Request objects collections how come the "Submit" is a querystring collection ?<BR><BR>Also, please check if the field name ""Date"" is allowed in teh database, it might be a reserved word and again you will have problem adding record.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts