Solved

insert data with ASP to oracle using form

Posted on 2004-04-12
3
603 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 51

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 115
Visual Studio hangs on running project 6 58
BATCH to EXE Converter 2 67
Octopus Deploy: need a Time Event that fires every midnight 2 29
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…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

756 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