Web Config :
connectionStrings>
add name="miConexion" connectionString="User Id=prueba;Password=prueba;Min Pool Size=3;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=2;Decr Pool Size=1;Max Pool Size=10;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=oracle)))" />
/connectionStrings>
En el aspx :
<%@Import Namespace="Oracle.DataAccess.Client"%>
<%@Import Namespace="Oracle.DataAccess.Types"%>
....
' se obtiene el string de conexion del web.config
Dim oradb As System.Configuration.ConnectionStringSettings
oradb = ConfigurationManager.ConnectionStrings("miConexion")
' se crea la conexion
Dim conn As New OracleConnection(oradb.ConnectionString)
Dim cmd As New OracleCommand
Dim RS As OracleDataReader
try
' se abre la conexión
conn.Open()
' Creación de SQL con bind variables
Dim sSQL As String
sSQL = "select codigo, descripcion FROM prueba"
' inicialización de valores
cmd.Connection = conn
cmd.CommandText = sSQL
' Ejecución y carga de DataReader
RS = cmd.ExecuteReader()
While RS.Read()
Response.Write(RS.Item("codigo") + " ---- " + RS.Item("descripcion"))
End While
Catch ex As Exception
Response.Write("ERROR:" + ex.Message)
Finally
'cierre de conexiones
conn.Close()
conn.Dispose()
End Try