It's my first time trying to do stuff with Dapper and Oracle database and I'm having trouble creating a connection.
I am able to connect to database through Oracle Sql Developer, but can't connect through code.
This is my connection string:
public static string oradb = @"Data Source=(DESCRIPTION="
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.232)(PORT=1521))"
+ "(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME=XE)));"
+ "User Id=SYSTEM;Password=root;";
This is the method in which I'm connecting
public static IEnumerable<T> ReturnList<T>(string procedureName, DynamicParameters param)
{
using (SqlConnection conn = new SqlConnection(oradb))
{
conn.Open(); <--- here I'm getting an error
return conn.Query<T>(procedureName, param, commandType: CommandType.StoredProcedure);
}
}
This is my tnsnames.ora connection:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.232)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
LISTENER_XE =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.232)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
System.Data.SqlClient.SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'