?
Solved

insert data with ASP to oracle using form

Posted on 2004-04-12
3
Medium Priority
?
656 Views
Last Modified: 2011-10-03
HI ALL

ineed the code for insert data to oracle database by using ASP form and HTMl

i'm using this code for reading data from my database


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
personal_ino
<%
        Set OraDatabase = Server.CreateObject("ADODB.Connection")
        OraDatabase.ConnectionString= "provider=MSDAORA.1;Data source=alm;user id=s019699;password=s019699;"
        OraDatabase.open
        Set osRecordSet = OraDatabase.Execute("SELECT FIRST_NAME from personal_info")
      

        while not osRecordSet.EOF
             response.write osRecordSet("FIRST_NAME") & "<br>"
             osRecordSet.moveNext
          wend

        
        osRecordSet.Close
        OraDatabase.Close
      %>
</body>

</html>


how can ifix this code or how can i write now code for insert data by form

thanx for helping

regards




0
Comment
Question by:moon_face
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 10806664
Here is an example on Insert data into database using ASP:

Test.asp:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="javascript">
      function validate(frm) {
            //Add your validation here..
            return true;
      }
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="processinsert.asp" onsubmit="return validation(this)">
  <table border="0" width="98%">
    <tr>
      <td width="30%" height="19" valign="top"><b>Value 1:</b></td>
      <td width="70%" height="19">
        <input type="text" name="value1" size="50" maxlength="255">
      </td>
    </tr>
    <tr>
      <td width="30%" height="19" valign="top">&nbsp; </td>
      <td width="70%" height="19" align="center">
        <div align="left">
          <p>
            <input type="submit"
          value="Submit" name="B2">
            <input type="reset" value="Reset" name="B1">
        </div>
      </td>
    </tr>
  </table>
</form>
</body>
</html>

processinsert.asp:

<%
      Response.expires = 0
      response.expiresabsolute = Now() - 1
      response.addHeader "pragma","no-cache"
      response.addHeader "cache-control","private"
      Response.CacheControl = "no-cache"
%>
<%
      dbConnectUser = "username"
      dbConnectPwd = "password"
      sid = "sid"
      user =  ""
      set conn=server.CreateObject("adodb.connection")
      conn.open "Provider=MSDASQL;DRIVER={Microsoft ODBC for ORACLE};UID=" & dbConnectUser &";PWD=" & dbConnectPwd & ";Server=" & sid

%>
<%
      Set Rs=Server.CreateObject("ADODB.Recordset")
      
      value1= Replace(request("value1"),"'","''")
            
      SQLStr = "Insert into tblTest (" & _
                   "value1 ) values ( " & _
                   "'" & value1 & "' " & _
                   ")"
      conn.execute SQLStr
      
      Conn.close
      Set Rs=Nothing
      Set Conn=Nothing

               //Redirect to thank you page if necessary
             response.redirect "thnkyou.asp"
%>

For more info on Oracle ConnectionString, see:

http://www.connectionstrings.com
http://www.able-consulting.com/ADO_Conn.htm

then look for Oracle..

Hope this helps
0
 

Author Comment

by:moon_face
ID: 10811297
thanx for ur aswer and i tried to work with it in my data base but ihave proplem with this lines

__________________________________


     value1= Replace(request("value1"),"'","''")
 
         
     SQLstr= "Insert into tblTest(value1)values("'"& value1 &"'")"
               
     conn.execute SQLStr
__________________________________

and idon't what the problem ,,, icreated tblTest table with value1 field

 create table tblTest
 (value1 varchar2(15) not null,
 constraint value1 primary key(value1));

and i modify the code according to my database as :

<%
     Response.expires = 0
     response.expiresabsolute = Now() - 1
     response.addHeader "pragma","no-cache"
     response.addHeader "cache-control","private"
     Response.CacheControl = "no-cache"
%>
<%
     Set OraDatabase = Server.CreateObject("ADODB.Connection")
       OraDatabase.ConnectionString= "provider=MSDAORA.1;Data source=alm;user

id=s019699;password=s019699;"
       OraDatabase.open

%>
<%

     
     Set Rs=Server.CreateObject("ADODB.Recordset")
     
     value1= Replace(request("value1"),"'","''")
 
         
     SQLstr= "Insert into tblTest(value1)values("'"& value1 &"'")"
               
     conn.execute SQLStr
     
     
     Conn.close
     Set Rs=Nothing
     Set Conn=Nothing


//Redirect to thank you page if necessary

             response.redirect "thnkyou.asp"
%>

unfortinatly igot this error

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'conn'
/processinsert.asp, line 24

thanx for ur cooperate



0
 

Author Comment

by:moon_face
ID: 10811836
thanx it works with me

thanx for help
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project

719 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