Delta
Suspenso
tenho o TNSNAMES.ORA com a informação necessária
e tenho o TNS_ADMIN a apontar para a pasta do TNSNAMES.ORA
tudo bem configurado, tanto que no VB6 não tenho problemas de conexão ao Oracle
No ASP.NET dá-me erro de TNS
há alguma coisa que deva fazer ? sou novo nisto
o código para tentar ligar é este :
====================================
Imports System
Imports System.Data
Imports System.Data.OleDb
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sConnectionString As String = "Provider=MSDAORA.1;User ID=v0efalm;password=cila01;Data Source=CEN;Persist Security Info=False"
Dim mySelectQuery As String = "SELECT sysdate FROM dual"
Dim myConnection As New OleDbConnection(sConnectionString)
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
'Set the parameter value.
'myCommand.Parameters.Add("@p1", OleDbType.Char, 5).Value = "Test%"
'Open connection to Oracle database.
myConnection.Open()
'Populate the DataReader.
Dim myReader As OleDbDataReader = myCommand.ExecuteReader()
Dim RecordCount As Integer
Try
While myReader.Read()
RecordCount = RecordCount + 1
Console.Write(myReader.GetString(0).ToString())
End While
If RecordCount = 0 Then
Console.Write("No data returned")
Else
Console.Write("Number of records returned: " & RecordCount)
End If
Catch ex As Exception
Console.Write(ex.ToString())
Finally
'Close all objects.
myReader.Close()
myConnection.Close()
End Try
End Sub
e tenho o TNS_ADMIN a apontar para a pasta do TNSNAMES.ORA
tudo bem configurado, tanto que no VB6 não tenho problemas de conexão ao Oracle
No ASP.NET dá-me erro de TNS
há alguma coisa que deva fazer ? sou novo nisto
o código para tentar ligar é este :
====================================
Imports System
Imports System.Data
Imports System.Data.OleDb
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sConnectionString As String = "Provider=MSDAORA.1;User ID=v0efalm;password=cila01;Data Source=CEN;Persist Security Info=False"
Dim mySelectQuery As String = "SELECT sysdate FROM dual"
Dim myConnection As New OleDbConnection(sConnectionString)
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
'Set the parameter value.
'myCommand.Parameters.Add("@p1", OleDbType.Char, 5).Value = "Test%"
'Open connection to Oracle database.
myConnection.Open()
'Populate the DataReader.
Dim myReader As OleDbDataReader = myCommand.ExecuteReader()
Dim RecordCount As Integer
Try
While myReader.Read()
RecordCount = RecordCount + 1
Console.Write(myReader.GetString(0).ToString())
End While
If RecordCount = 0 Then
Console.Write("No data returned")
Else
Console.Write("Number of records returned: " & RecordCount)
End If
Catch ex As Exception
Console.Write(ex.ToString())
Finally
'Close all objects.
myReader.Close()
myConnection.Close()
End Try
End Sub
Última edição: