Examples of connecting Oracle databases in ASP Dynamic Web page production

Source: Internet
Author: User
Oracle| News | data | database | Web

The following code can show that the current user can see all the users and tables that are interested and can put the contents of each table.

<%


Dim objorasession,objoradb


Dim Strdbuser,strdbpwd,strdbconn


call Connectdb ()


Sub connectdb ()


' Connection Database


on Error Resume Next


strdbuser = "Tmpuser" Connection username


strdbpwd = "rt45ps1w" User password


strdbconn = "sun450" Connection string


Set objorasession = Server.CreateObject ("oracleinprocserver.xorasession")


Set objoradb = objorasession.opendatabase (Strdbconn,strdbuser & "/" & strdbpwd,0)


If Err.number>0 then


Response.Write "<font color=red> Error:" & Err.Description & "</font>"


Response.End


End If


End Sub


Sub enddb ()


Set objoradb = Nothing


Set objorasession = Nothing


End Sub


Function gettablelist (str)


Dim strsql,strtmp


Dim objRS


strSQL = "Select At.table_name as tname,au.username as uname from All_tables at,all_users au Where au.username=at.o Wner ORDER by Au.username "


Set objRS = Objoradb.dbcreatedynaset (strsql,0)


While not objrs.eof


stra = objRS ("uname") & "." & objRS ("Tname")


If Str=stra then


strtmp = strtmp & "<option selected>" & Stra & "</option>"


Else


strtmp = strtmp & "<option>" & Stra & "</option>"


End If


Objrs.movenext


Wend


Set objRS = Nothing


gettablelist = strtmp


End Function


%>


<form name=form1 action= "index.asp" Method=post target= "main" >


<table width= "100%" border=0 align= "center" >


<tr><td>


all Tables: <select name= "TB" >


<%=gettablelist (tblname)%>


</select>


<input type=hidden name= "SUBMITC" value= "View" >


<input type=submit name= "Submit" value= "View Data" > <font color=red> (<%=strdbuser & "/" & Str Dbpwd & "@" & strdbconn%>) </font>


</td></tr>


</table>


</form>







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.