Solved

add new record.

Posted on 2004-04-10
1
152 Views
Last Modified: 2011-09-20
sorry i realized that i did not have the file included. I was so sure i included that file that i blindly copy pasted the code.   lol


just one more thing if you can help me. Basically this is a project me and my friend are working on and one of the pages is suppose to add new record to the database. i don't know it will not update it. I put values in the form and then it just clears the field but it does not add the record to the database.



<%Option Explicit%>
<!--#include virtual="/adovbs.inc"-->
<html>
<head>
<title>
</title>
</head>
<body bgcolor="#000066">

<H1 align=center><font color="blue">Registration</font></h1>

<form action="register.asp" method="post" >
<h2><font color="blue">Name:</font> <input type="text" name="nam" size=20>
<h2><font color="blue">Phone: </font><input type="text" name="pho" size=10>
<h2><font color="blue">Pin:</font> <input type="text" name="pinn" size=3><sub><font color="red">(*Optional)</font></sub>
<h2><font color="blue">Choose Plan:</font> <select name="plan">
<option selected> Student          $20.00 on the card
<option>Normal           $50.00 on the card
<option>Business          $100.00 on the card
</option>
</select>
<input type="submit" name="submit" value=" Submit ">
</form>

 





<%

 If request.form("submit")="Submit" then

Dim rs, sql, conn



      set conn= createobject("ADODB.Connection")


      conn.open "int213db"


      sql="Select * From abcTel where 1<> 1"

         
      Set rs = server.createobject("Adodb.recordset")
      
      
      rs.open "abcTel",  conn, adopenstatic, adlockoptimistic

      rs.addnew
      rs("client_name") = request.form("nam")
      rs("client_phone_number") = request.form("pho")
      rs("card_pin") = request.form("pinn")
      rs("card_plan_name") = request.form("plan")
      rs.update
      
 









rs.close
set rs=nothing
conn.close
set conn=nothing


end if
%>        
</body>
</html>


0
Comment
Question by:punjabijatt
1 Comment
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 100 total points
ID: 10796805
Try change:

rs.open "abcTel",  conn, adopenstatic, adlockoptimistic

to:

rs.open sql,  conn, adopenstatic, adlockoptimistic

?

or try this instead:

<%
 If request.form("submit")="Submit" then

Dim rs, sql, conn
     set conn= createobject("ADODB.Connection")

     conn.open "int213db"

sql="Insert into abcTel (" & _
     "client_name, client_phone_number, card_pin, card_plan_name " & _
     ") values (" & _
     "'" & request.form("nam") & "', '" & request.form("pho") & "', '" & request.form("pinn") & "', '" & request.form("plan") & "' " & _
     ") "
conn.execute sql
     
conn.close
set conn=nothing

end if
%>        

For the correct syntax to establish a connection, refer to:
http://www.connectionstrings.com
http://www.able-consulting.com/ADO_Conn.htm
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question