asp.net example of connecting Oracle databases

Source: Internet
Author: User
asp.net|oracle| Data | database

asp.net example of connecting Oracle databases


Just contact ASP.net, found in the. NET Framework version 1.1, there is a direct System.Data.OracleClient class library,

Used to access the Oracle database, but I'm still a 1.0 version here, and I don't support this object.

Here is an example of accessing a database through OLE DB, similar to the one in the ASP, and access to most databases, such as access.


<%@ Page language= "VB"%>

<%@ import namespace= "System.Data"%>

<%@ import namespace= "System.Data.OleDb"%>

<script runat= "Server" >

Sub Page_Load (Sender as Object, E as EventArgs)

Dim ConnectionString as String = "provider=oraoledb.oracle;" User Id=tmpuser; Password=rt45ps1w;data source=sun450; "

Dim CommandText as String = "Select * from ZSCRUSER.SMS_TK"

Dim MyConnection as New OleDbConnection (ConnectionString)

Dim mycommand as New OleDbCommand (CommandText, MyConnection)

Dim myreader as OleDbDataReader

Myconnection.open ()

Myreader=mycommand.executereader ()


' Way 1 use DataGrid to show the return data

' Bind directly to the DataGrid control

' Datagrid1.datasource=myreader

' Datagrid1.databind ()



' Or, as we do in the ASP, through a circular output of data, we format the appearance of


While Myreader.read ()

Response.Write (myreader ("title") + "<br>")

' Wend

End While

Myreader.close ()

Myconnection.close ()


End Sub

</script>




<body style= "Font-family:arial" >


&LT;HR size= "1"/>

<form runat= "Server" >

<asp:datagrid id= "DATAGRID1" runat= "Server" cellspacing= "1" gridlines= "None" cellpadding= "3" backcolor= "white" Forecolor= "Black" enableviewstate= "False" >


<itemstyle backcolor= "#DEDFDE" ></ItemStyle>

</asp:datagrid>

</form>

</body>




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.