Solved

insert data with ASP to oracle using form

Posted on 2004-04-12
3
604 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 52

Accepted Solution

by:
Ryan Chong earned 500 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Advice on Xojo as a development tool over VB. 4 90
draw a Christmas tree by using a nested loop? 26 105
Query Syntax 17 66
Using Third Party DLL with Access VBA 14 64
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

734 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